Global 404 page for a multilingual site

If you have the file /layouts/404.html, Hugo will create the /404.html page for you. However, in a multilingual setup this page will go into each language subdiirectory, so you get /en/404.html, /ru/404.html etc.

My problem is that render.com only recognises a 404.html as the default error page when it’s at the root of your site.

How can I have my 404 page created at the root, instead of under each language subdirectory?

Instead of

hugo

to create your site run:

hugo && cp public/en/404.html public/404.html

It’s a hack, but does what you need. I don’t believe that you will be able to tell Hugo to create only one single 404 page for multiple languages. (public/en/404.html depends on your structure of course)

see https://github.com/gohugoio/hugo/issues/5161

Thanks all, would be really nice to have #5161 resolved. Will use that hack until then.

Actually there is a much simpler way and I am cross posting it, because if anyone finds this topic via the forum search they need to know that there is no need for shell commands.

See: