HUGO

Term pages having other taxonomies – how to include them in listing?

Dear All,

Is it possible to have a loop in a taxonomy term template that will list not only the regular pages (using .Data.Pages) but also other taxonomy term pages that were assigned to current term page?

I have tags and products taxonomies and for some products I have _index.md files with short descriptions of what they are.

I would like to tag the term pages of products (with tags: […] in their front matters) so they will be listed on respective tag pages.

Is it easy doable via some other variable I’m not aware of?

Kind Regards,
Paweł

Hi there,

I’m not quite sure I understand what you are asking. It would be easier to help if you had a repo we can have a look at.

Did you mean something like this?

{{/*  terms.html  */}}
{{/*  list all tags  */}}
<ul>
{{ range .Pages }} 
<li><a href="{{.Permalink}}">{{.Title}}</a>
    <ul>
        {{/*  check if tags/foo/_index.md has products: lorem, ipsum  */}}
        {{ with .Params.products }}
            {{ range . }}
                {{ with site.GetPage (print "products/" . )}}
                <li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
                {{ end }}
            {{ end }}
        {{ end }}

        {{/*  regular pages with tags  */}}
        {{ range .Pages }}
        <li><a href="{{.Permalink}}">{{.Title}}</a>: {{.}}</li>
        {{ end }}
    </ul>
</li>
{{ end }}
</ul>

Edit:

Note that at this point as far as I know, you are not able to add taxonomies to taxonomies. So tags/foo/ will not show up as a page under /products/lorem/.