How to put in index all pages with tags

Sorry about that. It’s morning here in Seattle, and I have only had one cup of coffee. A poor excuse, but an excuse nevertheless.

Option 1

{{ $p := slice }}
{{ range site.Taxonomies.tags }}
  {{ range .Pages }}
    {{ $p = $p | append . }}
  {{ end }}
{{ end }}

{{ range uniq $p }}
  <h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
{{ end }}

Option 2

{{ range where site.Pages "Params.tags" "ne" nil  }}
  <h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
{{ end }}

The only limitation with the second approach is that it will include pages with an empty tag array:

tags = []
1 Like