Hugo

Access sub-variables in range cycle

Hello everyone!
I am working on a new template, and I have a part of my custom frontmatter defined as follows:

images:
- name: "1.jpg"
  ratio: 1.28
- name: "2.jpg"
  ratio: 1.33
...

Now I want to use this data in my template, thus I set up a cycle as follows:

{{ range .Params.images }}
  <img src="{{ .name }}">
  <span>{{ .ratio }}</span>
{{ end }}

To me it feels feel pretty straightforward, yet I get the following error:

can't evaluate field ratio in type string

I searched online, but the cases I could find seem related to other issues.
Could someone help me figure out what’s going on? I am sure it must be a little silly thing.

Nevermind, for some weird reason it seems working now. Must have been a weird formatting issue hidden somewhere.

EDIT: It happened again after manipulating some static content unrelated to the code above. Altering the incriminated file in any way and reverting back the changes seems to fix it. Is this a bug?

We cannot currently determine if it is a bug. Please follow the get help advice. :slight_smile: