I’m start using Hugo to create a multilingual docs site.
doc-1.md
doc-1.ja.md
doc-1.fr.md
doc-2.md
doc-2.ja.md
doc-2.fr.md
doc-3.md
doc-4.md
doc-5.md
The default language is en.
I would like when visiting ja site doc-3, doc-4 and doc-5 and also be displayed using the default language.
Which means even when doc-3.ja.md doesn’t exist, visiting /ja/doc-3 will show the content of doc-3.me. And it will be listed in the /ja/list list page as well.
It is like the i18n file, when a string doesn’t exist in one language it will fallback to the default languange.
Currently doc-3, doc-4 and doc-5 don’t exist and won’t be displayed in list.
Is there anyway to solve this?
I would like to let the language fallback to the default language and don’t want to create a duplicate *.lang.md before it’s being translated.
Either use a shortcode to render the English language content with .GetPage from within a doc-3.ja.html content file etc.
Or instead of using Hugo’s multilingual feature (as it is meant for translations of identical content), look into using language taxonomies. See the following discussion:
But I don’t think both solutions meet my requirements.
Since it’s gonna be a site for docs, it’s contents are for different languages based on the default en language. Using .GetPage still requires to create a target language file to make that doc to appear in the target language.
So I guess it is better to create a multi-language docs site using wiki since there is no better solution to use with Hugo?
You should try adding an aliases in the front matter of the english document that does not have a translated document.
—-
title: doc3
aliases: /ja/doc3
—-
The only way to create a real page available via list is to create a .md file. Therefore, you need to create a .md file with only the frontmatter supported either by a variable and shortcode or a custom layout that will do the magic.