# Range with two arrays

**URL:** <https://discourse.gohugo.io/t/range-with-two-arrays/45577>\
**Category:** support\
**Created:** [August 2, 2023, 1:44am UTC](https://discourse.gohugo.io/t/range-with-two-arrays/45577 "2023-08-02T01:44:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnsmith](https://avatars.discourse-cdn.com/v4/letter/j/d9b06d/32.png) [@johnsmith](https://discourse.gohugo.io/u/johnsmith)\
**Post date:** [August 2, 2023, 1:44am UTC](https://discourse.gohugo.io/t/range-with-two-arrays/45577/1 "2023-08-02T01:44:45Z")

</div>

Hi, so for my site I’m trying to fit two values into one range, kinda like this

Frontmatter:

```auto
info:
  - n: name1
    y: 2023
  - n: name2
    y: 2023

```

Code:

```auto
{{ range .Params.info }}
Name {{ .n }}<br>
Year {{ .y }}<br><br>
{{ end }}

```

It doesn’t work though. I get this error:  
`execute of template failed at <.n>: can’t evaluate field n in type string`

Where am I going wrong here?

Also this is where I found the solution I’m trying to use if it matters:

> [@Range from two arrays](https://discourse.gohugo.io/t/range-from-two-arrays/38410):
>
> Hey guys! in /content/blog/my-post.md I have two arrays FAQquestion: ["question about something", "second question", "third Q"] FAQanswer: ["answer no 1", "another answer", "answer no 3"] I want to add this to html head to have something like this \<script type="application/ld+json"\> { "@context": "https://schema.org", "@type": "FAQPage", "mainEntity": [ { "@type": "Question", "name": "{{ .FAQquestion}}", "acceptedAnswer": { "@type": "Ans…

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [August 2, 2023, 3:01am UTC](https://discourse.gohugo.io/t/range-with-two-arrays/45577/2 "2023-08-02T03:01:52Z")

</div>

Hugo’s YAML interpreter is a bit out of date, where n is false and y is true, so this:

```yaml
info:
- n: name1
  y: 2023
- n: name2
  y: 2023

```

is interpreted as:

```auto
[map[false:name1 true:2023] map[false:name2 true:2023]]

```

Quote the keys:

```yaml
info:
- "n": name1
  "y": 2023
- "n": name2
  "y": 2023

```

The early YAML spec mapped all kinds of things to true and false. Norway got the sharp end of the stick on that one.

---

<div class="post-metadata">

**Author:** ![johnsmith](https://avatars.discourse-cdn.com/v4/letter/j/d9b06d/32.png) [@johnsmith](https://discourse.gohugo.io/u/johnsmith)\
**Post date:** [August 2, 2023, 6:41am UTC](https://discourse.gohugo.io/t/range-with-two-arrays/45577/3 "2023-08-02T06:41:42Z")

</div>

Thank you for the reply!

Your solution worked for me. This helps a lot, I really appreciate it.

---

<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:** [August 4, 2023, 6:41am UTC](https://discourse.gohugo.io/t/range-with-two-arrays/45577/4 "2023-08-04T06:41:46Z")

</div>

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