Skip to content

Add optional fallback to default language for missing params in translated pages #11603

@TiGR

Description

@TiGR

Let's say you have items like image, date and tags in front matter of news item of your website, where tags is a taxonomy. These items are the same for a specific piece of news across all translations, since you have the same photo accompanying the news, the date and the category of a specific news item. So, you have to produce duplication, with different translations having the same params in front matter. It would be nice if hugo could optionally fallback to default language and take missing params from default language version.

Let's say you have to following file:

index.md:

---
title: News Title
image: img.jpg
date: 2023-01-23 04:56
tags:
  - foo
  - bar
---

News Content

Now, the only items here that have any translatable strings are title param and content itself. However, if I create translation file index.xx.md like this:

---
title: Translated News Title
---

Translated News Content

I would be missing params from default language. Surely, in my templates I could do a fallback by checking default language and taking params from there if these are missing. However, it won't work for taxonimies, and that content piece won't be added to specific tag pages in that specific language. So, I have to put taxonomies to the translation pages.

However, this produces a problem with duplication, where if something is changed in that taxonomy field, it should be also updated across all the translations. And the problem increases, since some content types might have many params with multiple taxonomies, and all of these params should not be translated but are supposed to be the same across all translations.

Making hugo optionally fallback to default language for missing params (including taxonomy handling) might be a perfect solution for this problem.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions