Dynamic Variable Expression Question?

Hi All,

Quite new to Hugo, I’m customizing a theme, and didn"t find a way to build dynamically an expression targetting an existing variable.

Here is what I want to do:

  • These 2 variables are existing :
    • .Site.Data.fr.SoftwareSkills,
    • Site.Data.en.SoftwareSkills

“fr” or “en” is coming from the variable “.Site.Language.Lang”. The question is simple, how to replace in the expression below the fixed “fr” field with a reference to “Site.Language.Lang”.

In other words, I want to replace :

  • {{ $SwSkills := .Site.Data.fr.SoftwareSkills }}

By something like this, but after spending 1h on Google, I did not get a chance to make it work :

  • {{ $SwSkills := .Site.Data.{{.Site.Language.Lang}}.SoftwareSkills }}

May be, this is not supported by the Go Template for HTML ?

Thanks for your feedback.

Maybe this discussion can help you: Multilingual data files

A sketch of what I would do:

{{ $data := index .Site.Data .Site.Language.Lang }}
{{ range $data.team }}


It did the trick. Thanks again.