Access Element Data Within a Range

I suspect I’m missing something obvious but I’m in desperate need of some guidance. I’m defining a list of images within the front-matter of a static page.

gallery:
  - title: "Title 01"
    filename: "filename01.jpg"
  - title: "Title 02"
    filename: "filename02.jpg" 

Then accessing from within my template.

{{ range $ind, $ele := .Params.gallery }}
  <img src="/img/gallery/{{ $ele.filename }}" title="{{ $ele.title }}"/>
{{ end }}

I’ve tried…

{{ range .Params.gallery }}
  <img src="/img/gallery/{{ .filename }}" title="{{ .title }}"/>
{{ end }}

Neither variant works.

I always get the same error.

“can’t evaluate field filenam in type string”

Please advise. I’m completely stuck.

Your YAML syntax isn’t correct. I’m no expert, but this resource looks good:

It looks like you want what’s referenced there as a twobytwotable: A list with two elements in each list item.

My YAML should be good. “gallery” is an array of hashes, each with two keys – “title” and “filename”.

You are right, it looks fine.

May be a bug in

gopkg.in/yaml.v2