Thanks. I’ve been looking at the example you linked to as well as this thread: Get all unique taxonomies of a page, but I’m still struggling.
I’ve managed to get the .Key
and all keywords
, but I can’t get uniq
to work correctly.
{{$books := where site.Pages "Section" "books"}}
{{range $books.GroupByParam "genre"}}
<h3>{{.Key}}</h3>
<ul>
{{range .Pages}}
{{range .Keywords}}
{{$.Scratch.Add "keyword" (slice .)}}
{{end}}
{{$.Scratch.Get "keyword" | uniq}}
{{end}}
</ul>
{{end}}
I’ve tried placing {{$.Scratch.Get "keyword" | uniq}}
in different places, but can’t get it to display the unique keywords for each genre.
Using similar code to the example I linked to above, I also can’t get the correct values.
{{$books := where site.Pages "Section" "books"}}
{{$slice := slice}}
{{range $books.GroupByParam "genre"}}
<h3>{{.Key}}</h3>
{{range .Pages}}
{{range $tag := .Keywords}}
{{$slice = $slice | append $tag}}
{{end}}
{{range $uniqueTags := $slice | uniq}}
{{$uniqueTags}}
{{end}}
{{end}}
{{end}}
Basically, I’ve tried two different ways to achieve the same result.