Getting Params into range call

Hello!

I’m new to Hugo. I do enjoy the good documentation, still there is one thing I can’t get working. I have a Site.Params as a text string and need to add this to a range call on a Site.Data. How do I need to write this? For you to imagine, it looks like this right now:

{{ range .Site.Data.videos.(.Site.Params.env }}
   {{.image}}
{{end}}

Of course, this produces an error right now.

Hi there,

You can use the index function: https://gohugo.io/functions/index-function/

Thank you! Just needed anyone pointing me in the right direction. :slight_smile: Thanks!

I used it as follows:

{{ range index .Site.Data.videos .Site.Params.env }}

This topic can be closed, thx!

1 Like

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