Iteration languages get parameter


I would like to iterate over all translations to build a language switching div.
I would like to define the icon definition within the config.yml under

        icon: "de"
        icon: "gb"

In my HTML file I’m using

 {{ .Site.Home.AllTranslations }}
 <a href="/{{- .Lang -}}/"<span class="flag-icon flag-icon-{{- ?? -}}"></span></a>
 {{ end }}

So my question is, how can I get the “icon” key and value of the language section within the config? So I need the code for the ??


We are lenient in the config parsing and support a few variations, but I think your problem will be easier to undertand if you follow the example in the docs:

    title = "My blog"
    weight = 1
      linkedin = ""
    title = "Mon blogue"
    weight = 2
      linkedin = ""
        help = "Aide"

Custom Params will be available in the language’s Site’s ´.Params`. So:

{{ .Site.Home.AllTranslations }}{{ .Lang }} {{ .Site.Params.icon }}{{ end }}


Also note that we have made this simpler in Hugo 0.53 with the config dir support, as you can have etc.

thanks, that’s a nice and easy solution

Maybe off-topic, but please, don’t use flags to represent languages.


Thanks for this off-topic hint, but I think it is a good idea

Surely unlike me, you don’t leave in a country (hint: flag) where several official languages (hint: no flag) are spoken. We have so to agree that we disagree.