Continuing the discussion from Trying to filter data files based upon a date field:
I tried practising Hugo’s range where
with data files.
# data/foo.yml
name: Lucas
parent: true
# data/bar.yml
name: John
parent: false
I would like to loop through entries where parent: true
.
From the linked discussion, I adapted @bep’s method without success.
{{ range where .Site.Data "parent" "eq" "true" }}
<p>name = {{ .name }}, parent = {{ .parent }}</p>
{{ end }}
How can I correct the loop? I’ve tried everything I can, like
{{ range where .Site.Data "parent" "true" }}
{{ range where $.Site.Data "Params.parent" "true" }}
etc.
Here’s the Hugo Template code: https://framagit.org/VincentTam/hugo-demo/blob/master/layouts/whatever/single.html
Test page: https://vincenttam.frama.io/hugo-demo/leaf-bundle/content2/