Joining content across languages

I’m running the following code to range over an archive of posts:

 {{$posts := (where (where .Site.RegularPages ".Params.options.unlisted" false) "Section" "!=" "instagram")}}
{{ range $posts.GroupByPublishDate "2006"}}

Works great but I have content in English and Portuguese, not all of it translated. Is there a way to join the missing content in Portuguese even if it doesn’t have an english translation?

reading the docs I found there is a function to merge content, the example would be something like what follows:

{{ $posts := .Site.RegularPages | lang.Merge $ptSite.RegularPages }}

I’m trying to figure out how to set the ptSite variable.

There are basically 2 “roads”:

  • By using .Translations
  • Or: .Sites

A quickly typed examples:

{{  $posts := .Site.RegularPages }}
{{ range .Site.Home.Translations }}
{{ $posts = .$posts | lang.Merge .Site.RegularPages }}
{{ end }}
2 Likes

Thank you @bep ! :smiley:

Just had to remove the dot in .$posts and it worked.

1 Like