For our podcast, each episode has one or more guests. As you might surmise, sometimes a guest appears on more than one episode. I would like to create a data file for each guest that contains the pertinent information about the guest (Name, bio, twitter handle, web url, etc), and then have each episode have frontmatter that lists the guests for that episode.
The problem I’m running into is pulling in the list of the guests and then passing that into a call to the data file.
In my frontmatter, I have this:
Guests = ["jhand", "srosenbaum"]
Each guest has a .yml file in /data/guests that looks like this:
Name: jhand
"Short Description": "He is a **jolly good** fellow."
"Twitter": "jasonhand"
Then, what I want to be able to do is something like this:
{{range $person := .Params.guests}}
{{.Site.Data.guests.$person.Name}}
{{ end }}
I seem to be missing something, as Hugo doesn’t want me to insert a variable into the middle of the path to the data. Ideas?
Thanks @bep - unfortunately that didn’t work. I used this code:
{{ range $person :=.Params.guests }}
{{ $person }}<br />
{{ (index .Site.Data.guests $person).Name}}
{{ end }}
which resulted in this:
ERROR: 2015/09/16 Error while rendering page episode/episode/chatops.md: template: theme/episode/single.html:17:17: executing "theme/episode/single.html" at <.Site.Data.guests>: can't evaluate field Site in type string
I tried modifying to {{ (index $.Site.Data.guests $person).Name}} thinking it was a dot issue, but that caused Hugo to crash, hard.