Internationalization: Generate fallback page for each language

Hi,

suppose the default language for my site is English, but I want to also offer the most important pages in German. The English root is in /en and the German root is in /de. So far so good. But now I also want to fallback to the English version for content that hasn’t been translated. Hugo lets me do this, but then all the links to those fallback pages point directly to /en/*. What I want Hugo to do instead is copy the untranslated English content into /de.

Let me illustrate this with an example. Let’s say I have the following files:

/content/page/good-morning.md
/content/page/good-morning.de.md
/content/page/good-evening.md

So one page has been translated, the other not. Right now this generates the following HTML pages:

/en/page/good-morning
/de/page/good-morning
/en/page/good-evening

What I want instead is:

/en/page/good-morning
/de/page/good-morning
/en/page/good-evening
/de/page/good-evening (using the same content as /en/page/good-evening)

Let me explain why. As it is right now, if any page links to “good-evening”, in the English or German version, the link will always go to /en/page/good-evening. From there, all further links will point to the English site. This is annoying for the user. If I choose the German site, I want to get all content in German if possible, and only fallback to English for content that’s not available in German. I don’t want to be permanently redirected to the English site if I click on just one article that’s not translated. I hope I am getting my point across.

Is this at all possible with Hugo?

Oh, and it would be best if the duplicated pages used a rel=canonical meta tag to point to the “original”, to avoid duplicate content for search engines.

1 Like

You can use the data from your english page in your german page’s template but you will still have to create a good-evening.de.md file with minimal Front Matter (title will suffice), as Hugo will not produce a page without a an attached “content file”.