Given a website with :
- only one section named “post” in content/
- one related index named “category”
This is how I implemented it, I want to do some kind of reverse indexing: retrieve all existing values of that index, make it a unique list, iterate through that list and get all matching pages using RelatedTo.
Could it be done differently and faster? At least without having to use.Scatch?
{{range .Site.Pages }}
{{ $.Scratch.Add "categories" (slice .Params.category) }}
{{end}}
...
{{ range (uniq ($.Scratch.Get "categories")) }}
<h5>{{ . }}</h5>
{{ range $.Site.RegularPages.RelatedTo ( keyVals "category" . ) }}
<a href="{{ .URL }}">{{ .Title }}</a>
{{ end }}
{{ end }}
I’m trying to hack Hugo into some sort of wiki-style website