zeon-studio / hugoplate

Hugoplate is a free starter template built with Hugo and TailwindCSS that will save you hours of work.
https://zeon.studio/preview?project=hugoplate
MIT License
899 stars 243 forks source link

404 Defaults to English in Multilingual Site #115

Closed ruskinik closed 7 months ago

ruskinik commented 7 months ago

What is your Hugo Extended Version

0.124.1

What is your Go Version

1.21.5

What is your Node.js Version

21.7.3

Check for Existing Issues

Expected Behavior

In layouts/404.html I have:

<h1 class="h2 mb-4">{{ i18n "error404" }}</h1>
<div class="content">
  <p>{{ i18n "error404Message" }}</p>
</div>

In i18n/en.yaml:

error404: Page not found
error404Message: The page you're looking for doesn't exist at this URL. That's all we know.

And i18n/fr.yaml:

error404: Page non trouvée
error404Message: La page que vous recherchez n'existe pas à cette URL. C'est tout ce que nous savons.

When we go to, e.g., example.com/fr/foo, the French version is expected but the English one is shown. This is evident from checking the source of the rendered 404 page which has lang="en-us" or adding {{ .Site.Language.Lang }} to 404.html and it will return en from example.com/fr/foo.

Steps to Reproduce

In 404.html

<h1 class="h2 mb-4">{{ i18n "error404" }}</h1>
<div class="content">
  <p>{{ i18n "error404Message" }}</p>
</div>

Code Reproduction URL

No response

Additional Information

No response

tfsomrat commented 7 months ago

Hey @ruskinik, I have added support for language based 404 page. here is the changes https://github.com/zeon-studio/hugoplate/commit/f994a8b6e66e8f751bb789c960ad31a5cc894b98 please download the latest version.

ruskinik commented 7 months ago

Maybe I'm missing something but it didn't solve the problem.

http://localhost:1313/fr/foo shows English 404 page.

tfsomrat commented 7 months ago

please start from scratch by re-downloading the theme. and let me know if it works...

On Mon, Apr 15, 2024, 5:48 PM Nikolai @.***> wrote:

Maybe I'm missing something but it didn't solve the problem.

  • npm run update-theme
  • copied 404.en.html from themes to layouts
  • added 404.fr.html to layouts with French 404

http://localhost:1313/fr/foo shows English 404 page.

— Reply to this email directly, view it on GitHub https://github.com/zeon-studio/hugoplate/issues/115#issuecomment-2056637170, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOAMCY2U6ZF2ZBHSG75WZ23Y5O475AVCNFSM6AAAAABGGCRIK6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJWGYZTOMJXGA . You are receiving this because you commented.Message ID: @.***>

ruskinik commented 7 months ago

It works, thanks. However, solving one problem, it created another by changing the URL structure from example.com/foo to example.com/en/foo. Is it possible to keep the default URL structure?

tfsomrat commented 7 months ago

I don't think so, because when you enable defaultContentLanguageInSubdir it will add the language path to the URL. but still I am going to check if it works