404 page with i18n

Just want to confirm I’m current on the state of the art in hugo on this issue. If I have:

defaultContentLanguageInSubdir = true

and default language is set to some language code say “en” and I have one 404 layout:

layouts/404.html

Can I have //404/ for each lang code in set of lang codes defined for the project with a fallback to the default lang 404 page? So if (by example):

Assume project lang codes = [“en”, “es”]
/en/thispagedoesnotexist -> /en/404.html
/es/thisonedoesexisteithr -> /es/404.html
/fr/nopedoesnotexisteither -> /en/404.html
/thisonedefinitelydoesntexisteither -> /en/404.html

As it is right now I’m actually having trouble even doing any 404 page. Please help! Ty

UPDATE: I just noticed that in hugo v0.73.0 you can do redirect and header settings in the config file. Could this solve the issue?

I’m not really sure how or if this can be done in Hugo itself, but, it can definitely be configured using redirects on the server. Depending on the server you’re using to host the website, you’d have to write the redirects accordingly.

I confirm that this works (can’t say if I’m on the state of the art). My MoodleBox website uses exactly these settings, with some i18n instructions for correct localisation. See: