Sharing front mater variables within a page-bundle with multiple languages

Hi, first time here, sorry if I misunderstood any of the rules about requesting help.

Well, I have a HUGO based site, I have a page-bundle multi language, currently is not so complex, but will be.

It has the following structure:

content
\ section
  \ page-bundle-1
    \ index.en.md
      index.es.md
      index.it.md
  \ page-bundle-2
    \ index.en.md
      index.es.md
      index.it.md

I’m looking for the ability to share different front-matter values between languages, and within page bundle, something like “cascade” does with sections. Is it possible?

Given the current scenario, page-bunde-1 if this feature exists will use the same tags, categories, series, and many custom configurations such cover configuration to all languages, easy to change anytime and apply to all quickly.
Not relevant, but tags, series, and categories are translated before render to its current language, that’s why any language can have same values.

I tried to use an _index.md and index.md with headless, draft, type single, and any combination of them with no luck.

Any thoughts?
Thanks in advance.

This is not possible.

If you have custom parameters that you need to share between pages, stuff it in a data file to be shared between translations.

Thanks, I knew about this path, but will be a pain to maintain per article in a long term.

I did what you suggested, I use a shared.md file that contains all shared (custom) values, it’s a half-solution but is way better than nothing.

For more detailed explanation, check here: Hugo - Share front matter values within page-bundle in a multi-language site

Thanks a lot

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.

So… this is possible with a partial.

Use a partial template to get the current language’s front matter value, and fallback to another language’s front matter value based on language weight (or alphabetically if weight is not set). For example:

layouts/_default/baseof.html
{{ with partial "get-page-param.html" (dict "page" . "param" "description") }}
  <meta lang="{{ .lang }} "name="description" content="{{ .value }}">
{{ end }}

layouts/partials/get-page-param.html
{{ $value := "" }}
{{ $lang := ""}}
{{ with index $.page.Params $.param }}
  {{ $value = . }}
  {{ $lang = $.page.Language.Lang }}
{{ else }}
  {{ range $p := $.page.Translations }}
    {{ with index .Params $.param }}
      {{ $value = . }}
      {{ $lang = $p.Language.Lang }}
      {{ break }}
    {{ end }}
  {{ end }}
{{ end }}
{{ return (dict "value" $value "lang" $lang) }}