Just getting started with Hugo, and so far I’m loving it!
My site is international… I’ll be translating some, but not all content - some never, some will be delayed.
I understand that if use i18n strings and one isn’t translated it will fallback to the default language - which is great - but what about when I use translation within content - for example:
So in this case, I have three translations - the original in English and then French an German.
Now lets say I create a new page:
/content/newpage.md
/content/newpage.fr.md
But for whatever reason I don’t create a German version - is it possible to get Hugo to fallback and generate a page in the default language - but still as newpage.de.md so that users don’t get a 404 when they visit the page navigating through the German version of the site?
What you ask for is not currently possible in Hugo, but I’m not sure I understand the requirement. You will only get a 404 if you actually link to that non-existing page, and if you do a .Site.RegularPages on the German site you will only get exsiting German pages. Also see the .Translations on each page; there should not be possible to get a link from Hugo’s objects that creates a 404. And it would seem a little odd if we created a English content page to replace a German one.
There is, however, a similar GitHub issue, that makes more sense to me. See:
In the latest Hugo, v0.25, you can also have templates per language (i.e. /layouts/index.de.html), and this also includes shortcodes, which is a big win for bigger multilingual sites.
I’ve currently got a very similar use case for generating a user manual website. We have not created translations for every page in the manual, and would like the english versions of untranslated pages to still be available when viewing the manual in french or german.
This solution works but is not optimal, in my case I wanted to make kate-editor.org translatable (using gettext) but It would be a useless task for the KDE translators to translate all the content way back to 2004.