I have a multi-language site and when the page is missing on the second language, I get 404 pages in the main language. I expect to get 404 on the second language.
I have defaultContentLanguageInSubdir: false
I use separate 404.md with layout: '404' in frontmatter, 404.md presents in content/ for each language and the layout in layouts/_default/404.html
Please note the 404.html file should be at the root of the layouts folder. If you need it to work on multilingual sites, you need to translate it using i18n files.
Alternatively, you can create files like 404.md, 404.es.md etc and add the url: 404.html in the front matter. Then add language specific content in there. It will be copied to the public folder of each language.
This helps to change the 404.html for both languages, but this does not resolve the problem.
For some reason, this returns a 404 for the default language.
In the language switcher, the current language becomes defaultLanguage, too. I can switch the language to en (the second language here), and I get the English 404, and the switcher becomes correct. But such behavior looks wrong.
git clone --single-branch -b hugo-forum-topic-53209 https://github.com/jmooring/hugo-testing hugo-forum-topic-53209
cd hugo-forum-topic-53209
hugo server
# See https://gohugo.io/getting-started/configuration/#_404-server-error-page
[[redirects]]
from = '/en/**'
status = 404
to = '/en/404.html'
[[redirects]]
from = '/**'
status = 404
to = '/404.html'
Thanks, thatβs exactly what I have expected. The problem was with gohugo version. In one of my instances, it was 0.124 and it was broken. On another with 0.139 it works like expected.