# Iterating over translated content in the config file

**URL:** <https://discourse.gohugo.io/t/iterating-over-translated-content-in-the-config-file/30466>\
**Category:** support\
**Tags:** i18n\
**Created:** [January 7, 2021, 8:31am UTC](https://discourse.gohugo.io/t/iterating-over-translated-content-in-the-config-file/30466 "2021-01-07T08:31:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![unjello](https://avatars.discourse-cdn.com/v4/letter/u/a698b9/32.png) [@unjello](https://discourse.gohugo.io/u/unjello)\
**Post date:** [January 7, 2021, 8:31am UTC](https://discourse.gohugo.io/t/iterating-over-translated-content-in-the-config-file/30466/1 "2021-01-07T08:31:56Z")

</div>

I am translating the index page. Some content in config file is common for all languages, some changes. In nested structures when I translate partially and reference directly everything works, i.e.:

```
languages:
  en:
    params:
      home:
        button:
          text: Home
  de:
    params:
      home:
        button:
          text: Titelseite
params:
  home:
    button:
      url: /

```

so in the template when I refernce it direclty via something along the lines of:

```
<a href="{{ .Site.Params.home.button.url }}>{{ .Site.Params.home.button.text }}</a>

```

everything works. The problem starts when I would like to have a list of some kind, let’s say, affiliated sites:

```
languages:
    en:
       params:
         sites:
           - description: A friendly site 1
           - description: A friendly site 2
    de:
       params:
         sites:
           - description: eine freundliche Website 1
           - description: eine freundliche Website 2
params:
  sites:
    - url: friendly-website-1.com
    - url: friendly-website-2.com

```

Simple iteration via range shows only translated “copy” of the map entry, so there is description element but url is empty. I tried to iterate via {{ range $i, $v := .Site.Params.sites }} and then reference elements via {{  
(index .Site.Params.sites $i).url }}  
but it does not work either.

I have also tried to make it a map instead of an actual array, like:

```
languages:
    en:
       params:
         sites:
           1:
               description: A friendly site 1
           2:
               description: A friendly site 2
    de:
       params:
         sites:
           1: 
               description: eine freundliche Website 1
           2: 
               description: eine freundliche Website 2
params:
  sites:
    1:
      url: friendly-website-1.com
    2:
      url: friendly-website-2.com

```

But it does not seem to work either. Any ideas how to translate an array like this without repeating all the redundant information that would be common across languages?

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [January 7, 2021, 11:12am UTC](https://discourse.gohugo.io/t/iterating-over-translated-content-in-the-config-file/30466/2 "2021-01-07T11:12:04Z")

</div>

Put it in a `data/stuff.toml` file and load/iterate via `site.Data.stuff...`?

> **[Data Templates](https://gohugo.io/templates/data-templates/)**
>
> In addition to Hugo's built-in variables, you can specify your own custom data in templates or shortcodes that pull from both local and dynamic sources.
