How to list all singular site taxonomies?

I want to list the singular version of all site taxonomies.

My attempt

{{ $taxonomies := slice }}
{{ range $k, $v := site.Taxonomies }}
    {{ $taxonomies = $taxonomies | append $k }}
{{ end }}

This gives me a slice of the plural form all the site’s taxonomies, but I’m hoping to get their singular forms.

Mmmm the Singluar information is only available on the page itself.

Either rely on the singularize function which in english usually works pretty well. (no other language supported though)

Or grab the page of the taxonomy, using the $k string, pending your dir structure is conventional:

 {{ $taxonomies := slice }}
     {{ range $k, $v := site.Taxonomies }}
        {{ with site.GetPage (print "/" $k) }}
            {{ $taxonomies = $taxonomies | append (.Data.Singular) }}
        {{ end }}
    {{ end }}
{{ end }}
3 Likes

Thanks, I also thought of using the taxonomy page context but was hoping for a simpler solution. I think singular would do the trick for me right now!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.