What syntax do I use for array in `.Params.image`?

I’m converting to Hugo’s internal templates for Twitter and OpenGraph, from a hand-rolled solution I made a while back. This is mainly so I can assign multiple images to a page, use them in Twitter cards and use them in a photo gallery.

In the process, I’ve converted all the frontmatter image: https://… to an array

- https//…

But I’m really rusty and can’t find the syntax for converting .Params.image to using an array. Something like .Params.image[0]??

Any help gratefully received! :slightly_smiling_face:

They call arrays “slices” in Go… Weird enough :wink: And you “range” through them

{{ range .Params.image }}
    {{ . }} <<< will print the url of the image
{{ end }}
1 Like

Thanks so much for the swift reply, really helped me out :+1:

For anyone who’s looking, this is how you access the index of the array:

{{ (index .Params.image 0)}}

From StackOverflow :slight_smile: