Custom 404 per language

I was using 404.html and 404.pt.html in /layouts/ to serve different pages when the server returned a 404 in the default language or Portuguese.

Looking at it today, both of the built files are the initial 404.html. Did something change in the way Hugo builds this page?

2 Likes

You have to find a way to config different 404 pages in your web server :frowning:
At best implement both languages in one page.

The server is working like intended, the problem here is that the page built in /404.html and /pt/404.html are the same.

with this hint

try with 404.pt.html

Yes, that’s my current setup and it was working.

Could it be connected to your earlier issue (that I can’t find now)? I remember we had a little back and forth about something related to PT.

I am pretty sure that /layouts/404.pt.html is supposed to be the 404 page for Portuguese and we have a bug here.

Does Hugo debug anything specific with hugo --i18n-warnings?

That one was about resources, but maybe it is connected with this one.

Just tried i18n-warnings and it built like expected, with no error.

Same problem here. Following Custom 404 Page in the docs, I would assume adding a layouts/404.de.html should work, but it doesn’t.

I have the same problem with Github Pages.

My blog have two languages and the 404.html is in the root of both folders, but it is not rendering.

Is there any known solution?

It seems that Hugo does not support translation by filename for 404 pages.

I am using the i18n function to translate strings within the singe 404.html file.

Also using i18n function. See this working example: