I have a collection of .json files in site/data/partners/. Sample content is:
{
"title": "Schweizerische Eidgenossenschaft",
"image": "/img/schweizerische-eidgenossenschaft.png",
"link": "https://www.sem.admin.ch/",
"type": "partner",
"city": []
}
Note the “type” key and “partner” value. The “type” key has only a few supported values, and I want to display partners with a particular value for this key.
Displaying all the partners works, with a simple range like:
<ul>
{{ range $.Site.Data.partners }}
<li>{{ .title }} : {{.type}}</li>
{{ end }}
</ul>
That shows all the partners, as expected.
Using an “if” test in the middle also works:
<ul>
{{ range $.Site.Data.partners }}
{{ if eq .type "partner"}}
<li>{{ .title }} : {{.type}}</li>
{{ end }}
{{ end }}
</ul>
This only shows partners where “type” equals “partner”.
From reading the “where” docs I expected that this would also work:
<ul>
{{ range where $.Site.Data.partners "partner" "type"}}
<li>{{ .title }} : {{.type}}</li>
{{ end }}
</ul>
But it doesn’t – I get no output. There are no errors or warnings in the console, hugo version
shows
Hugo Static Site Generator v0.58.2-253E5FDC windows/amd64 BuildDate: 2019-09-13T08:06:10Z
I’m missing something obvious, but I’m damned if I can see it…