Pass key to data map in content front matter?

Hey all, I am having some trouble. I am building a template for robotics teams where a team just needs to update a yaml json file with season information and robot statistics, and a page will automatically be generated for them.

Essentially, I am cloning this to hugo: https://www.team254.com/first/

I have determined that it is currently not possible to range over a datafile and generate multiple pages. So I was thinking that I would have a datafile like this:

season1:
    name: A
    year: 2010
    robot: 
      name: sam
season2:
    name: B
    year: 2011
    robot: 
      name: Dave

and in a pages front matter I would pass in something like:

key: "season1"

However, I haven’t been able to find a way to access that key.

.Site.Data.seasons[.Params.key]

I wish something like that would work. If this is not possible does anyone have any recommendations on how to architect this? I would really prefer not to have 100 different params in the front matter outlining robot statistics, competition statistics, photos, and video URLs.

Thanks for the help!

There was a similar thread a couple of weeks ago that may help you:

https://discourse.gohugo.io/t/work-around-for-making-pages-from-data/

Try

{{ index .Site.Data.seasons .Params.key }}
2 Likes