Hi,
I have been looking at Mike Dane’s tutorial on data files with Hugo and I have the range working when I want to loop through the list without a problem but when I try and just select one bit of data (say on a single.html page) I cannot get the “where” working.
This is his code:
{{ range $.Site.Data.states where "name" eq .title }}
<h2>{{ .name }}</h2>
<p>{{ .capital }}</p>
Location : {{ .lat }}, {{ .long }}
{{end}}
But I constantly get these errors
execute of template failed at <$.Site.Data.states>: states is not a method but has arguments
The data file I’m using is data/states.json
with this content
{
"AL": {
"name": "Alabama",
"capital": "Montgomery",
"lat": "32.361538",
"long": "-86.279118"
},
"AK": {
"name": "Alaska",
"capital": "Juneau",
"lat": "58.301935",
"long": "-134.419740"
}
}
Does anyone have any idea where I’m going wrong?
Thanks
Al