Dear community,
I’ve been struggling on this for the past 3 hours.
My FrontMatter includes a YAML map:
gallery:
- title: nice-bedroom
image: "/img/projects/nice-bedroom.jpg"
thumbnail: "/img/projects/nice-bedroom.jpg"
- title: nice-desk
image: "/img/projects/nice-desk.jpg"
thumbnail: "/img/projects/nice-desk.jpg"
- title: nice-entrance
image: "/img/projects/nice-entrance.jpg"
thumbnail: "/img/projects/nice-entrance.jpg"
As you could have understood, I want to output a gallery. Given the following template code:
{{ range $image := .Params.gallery }}
{{ reflect.IsMap $image }}
{{ index $image "title" }}
{{ end }}
I get the following error: executing "main" at <index $image "title">: error calling index: cannot index slice/array with type string
.
The weird thing it that the IsMap
function return true
. If I output $image
, I get the following output:
map[image:/img/projects/nice-bedroom.jpg thumbnail:/img/projects/nice-bedroom.jpg title:nice-bedroom]
I’ve tried other ways of creating the YAML without any success. Any idea is welcome!
Thank you!
Hugo Static Site Generator v0.60.1-96066756 linux/amd64 BuildDate: 2019-11-29T14:57:23Z
GOOS="linux"
GOARCH="amd64"
GOVERSION="go1.13.4"