I have a blog that has defaultContentLanguage = 'fi' and all the posts in content/posts. I’ve written a single post in English, and I’d like the behaviour of the theme and the HTML metadata etc. to become English for that single post as well. I don’t want to the site to render separate /en/ and /fi/ subdirectories or have any other separation between the two languages. I don’t want any of my existing content to move or change.
Then set defaultContentLanguageInSubdir = false (which is the default) in your site configuration.
There will still be a fi directory for the the fi sitemap and a redirect from /fi to the root of the public directory.
Disabling the rendering of /en can be done, but it’s messy, and I wouldn’t do it.
git clone --single-branch -b hugo-forum-topic-52231 https://github.com/jmooring/hugo-testing hugo-forum-topic-52231
cd hugo-forum-topic-52231
hugo server
hugo v0.111.3+extended linux/amd64 BuildDate=2023-03-16T08:41:31Z VendorInfo=debian:0.111.3-1
ERROR 2024/11/01 19:01:31 render of "section" failed: "/home/ronja/src/hugo-forum-topic-52231/layouts/_default/baseof.html:2:15": execute of template failed: template: _default/list.html:2:15: executing "_default/list.html" at <site>: can't evaluate field LanguageCode in type *langs.Language
ERROR 2024/11/01 19:01:31 render of "home" failed: "/home/ronja/src/hugo-forum-topic-52231/layouts/_default/baseof.html:2:15": execute of template failed: template: _default/home.html:2:15: executing "_default/home.html" at <site>: can't evaluate field LanguageCode in type *langs.Language
ERROR 2024/11/01 19:01:31 render of "taxonomy" failed: "/home/ronja/src/hugo-forum-topic-52231/layouts/_default/baseof.html:2:15": execute of template failed: template: _default/list.html:2:15: executing "_default/list.html" at <site>: can't evaluate field LanguageCode in type *langs.Language
Error: Error building site: failed to render pages: render of "page" failed: "/home/ronja/src/hugo-forum-topic-52231/layouts/_default/baseof.html:2:15": execute of template failed: template: _default/single.html:2:15: executing "_default/single.html" at <site>: can't evaluate field LanguageCode in type *langs.Language
Second, the example post files you made look like one is supposed to be a translation of the other. This is not my intention. The single English post I wrote is stand-alone content that is not intended to have a version in Finnish.
Perhaps the key takeaway for my usecase is that I can override the /en/... url in the post’s front matter, and then I can just ignore the /en/ subdirectory even though it’s technically there? I can live with that.
Everything looks reasonable with this setup, except post-2 doesn’t appear in the index alongside post-1. In fact, I don’t think post-2 is reachable from anywhere.