404 layout in local multilingual environment

I have followed Custom 404 Page setup by creating 404.html in my layout. As my website is multilangual I have set 404.en.html as well and in netlify I got rule set to use right 404 page based on site language

/en/* /en/404.html 404

My question is on local environment. Some time ago it was implemented that hugo will resolve 404 errors and serve 404 website. Its working fine for main language, but anything for other language in local environment is returning main language 404 page instead localised.

Is that a bug or limitation.

I always can access it /en/404.html to see how it will look in production environment, but still, in local?

You need to configure the language inside config/development/server.toml (I found this solution somewhere on this forum by @jmooring ).

[[redirects]]
	from = '/en/**'
	to = '/en/404.html'
	status = 404

[[redirects]]  # Default language should be last.
	from = '/**'
	to = '/404.html'
	status = 404

But perhaps it should be documented on the 404 page in the docs.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.