# Ranging over a set of values

**URL:** <https://discourse.gohugo.io/t/ranging-over-a-set-of-values/50274>\
**Category:** support\
**Created:** [June 13, 2024, 7:02am UTC](https://discourse.gohugo.io/t/ranging-over-a-set-of-values/50274 "2024-06-13T07:02:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![attractmore](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/attractmore/32/20816_2.png) [@attractmore](https://discourse.gohugo.io/u/attractmore)\
**Post date:** [June 13, 2024, 7:02am UTC](https://discourse.gohugo.io/t/ranging-over-a-set-of-values/50274/1 "2024-06-13T07:02:51Z")

</div>

Hi

I’ve been scratching my head about this for a while and have been though the docs and look at various support threads but have not yet been able to resolve this.

In the YAML front matter I have

```auto
group1FeatureSet1:
  - feature:
    heading: "Device Enrolment"
    description: "Automatically enrols devices into your Mobile Device Management (MDM) solution."
  - feature:
    heading: "Managed Apple IDs"
    description: "Create and manage Apple IDs specifically for your organisation. "

```

and I want to range over the features and display the heading and description. This is the current version of my code

```auto
        {{ with .Params.groupFeatureSet1 }}
          <ul>
            {{ range . }}
              <li>
                <h3>{{ .heading | safeHTML }}</h3>
                <p>{{ .description | safeHTML }}</p>
              </li>
            {{- end -}}
          </ul>
        {{- end -}}

```

Nothing is displayed and no error is shown. There’s something I’m misunderstanding here. Can anyone help?

Thanks

---

<div class="post-metadata">

**Author:** ![AncientDF](https://avatars.discourse-cdn.com/v4/letter/a/8edcca/32.png) [@AncientDF](https://discourse.gohugo.io/u/AncientDF)\
**Post date:** [June 13, 2024, 7:21am UTC](https://discourse.gohugo.io/t/ranging-over-a-set-of-values/50274/2 "2024-06-13T07:21:53Z")

</div>

I believe this is rather a Go templating issue, rather than a Hugo one. I’ve not tried this but, I would adapt my template to match something like [this](https://docs.dynatrace.com/docs/manage/configuration-as-code/monaco/guides/configuration-as-code-advanced-use-case)

---

<div class="post-metadata">

**Author:** ![irkode](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/irkode/32/26135_2.png) [@irkode](https://discourse.gohugo.io/u/irkode)\
**Post date:** [June 13, 2024, 7:45am UTC](https://discourse.gohugo.io/t/ranging-over-a-set-of-values/50274/3 "2024-06-13T07:45:04Z")

</div>

1. `group1FeatureSet1` is a custom parameter - with recent hugo versions this should be under `params` key.

2. you have a typo in the loop:

3. no need to pipe to safeHTML if you just have text in the field

---

<div class="post-metadata">

**Author:** ![attractmore](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/attractmore/32/20816_2.png) [@attractmore](https://discourse.gohugo.io/u/attractmore)\
**Post date:** [June 13, 2024, 10:37am UTC](https://discourse.gohugo.io/t/ranging-over-a-set-of-values/50274/4 "2024-06-13T10:37:18Z")

</div>

Thanks for your speedy reply. I looked at the YAML and used the link on the page you suggested to convert it to JSON. It wasn’t quite what I expected!

I tried other ways of formatting the front matter but without any change to the result.

---

<div class="post-metadata">

**Author:** ![attractmore](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/attractmore/32/20816_2.png) [@attractmore](https://discourse.gohugo.io/u/attractmore)\
**Post date:** [June 13, 2024, 10:43am UTC](https://discourse.gohugo.io/t/ranging-over-a-set-of-values/50274/5 "2024-06-13T10:43:29Z")

</div>

Thanks. I have used the newer syntax for params (after upgrading my version of HUGO) and fixed that typo you pointed out.

Front matter is now

```auto
params:
  group1FeatureSet1:
    - heading: "Device Enrolment"
      description: "Automatically enrols devices into your Mobile Device Management (MDM) solution."
    - heading: "Managed Apple IDs"
      description: "Create and manage Apple IDs specifically for your organisation."

```

The page now contains

```auto
      {{ with .Params.group1FeatureSet1 }}
      <div class="list-plus-callout">
        {{ partial "service-key-features-list.html" . }}
      {{- end -}}
      </div>

```

And the partial is

```auto
  <ul>
    {{ range . }}
      <li>
        <h3>{{ .heading }}</h3>
        <p>{{ .description }}</p>
      </li>
    {{- end -}}
  </ul>

```

This works perfectly and I’m pleased to have been able to hive off code into a partial as a I have several occurrences of these FeatureSets.

Thanks for your help.

Roger

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [June 15, 2024, 10:44am UTC](https://discourse.gohugo.io/t/ranging-over-a-set-of-values/50274/6 "2024-06-15T10:44:01Z")

</div>

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