{{ define "main" }}
{{ $uniqueCategories := slice }}
{{ $tags := .Data.Pages }}
{{ $termsWithoutCategories := slice }}

{{ range $tags }}
    {{ $categories := .Params.categories }}
    {{ if $categories }}
        {{ range $categories }}
            {{ $uniqueCategories = $uniqueCategories | append . }}
        {{ end }}
    {{ else }}
        {{ $termsWithoutCategories = $termsWithoutCategories | append . }}
    {{ end }}
{{ end }}

{{ $uniqueCategories = $uniqueCategories | uniq | sort }}
{{ $termsWithou