We've retired the forum in favor of GitHub Discussions.

New conversations can be started on GitHub. Existing conversations will remain for a while longer.

Head over to GitHub →

How to use taxonomy title as page title, given taxonomy slug?

JT September 7, 2020 by JT

UPDATE/NOTE: When posting originally, this discussion just 404d, so I tried again and ended up creating a duplicate (https://statamic.com/forum/4846-use-taxonomy-title-as-page-title-given-taxonomy-slug). That one also is 404ing as of now, but this one is up and running. The duplicate can be removed or closed later. Sorry!

I may also be missing something rather obvious, and have already referenced a ton of previous discussions including these ones (https://statamic.com/forum/4169-get-taxonomy-title-from-taxonomy-slug and https://statamic.com/forum/4226-correct-routing-for-collection-categories), but no solutions appear to work for the problem I'm trying to solve.

I need the following route to output the correct taxonomy title as the page title, based on the taxonomy slug in the URL.

    template: art-portal
    title: '{{ taxonomy_title_based_on_taxonomy_slug_in_route }}'

Everything else about my setup works correctly:

  • The route-defined template (and default layout) work as expected
  • The page content works as expected (shows items in the "art" collection, filtered by the given "portals" taxonomy slug)
  • title: '{{ slug }}' as a test will output the correct slug from the URL as the page title.

Methods I've tried to get the correct title output:

  • Variations on {{ taxonomy:portals slug:is="slug" }}{{ title }}{{ /taxonomy:portals }}, none of which appear to work and many of which will cause my virtual machine to seize up.
  • Some grasping-at-straws attempts to {{ relate }}
  • Attempting both of the above by trying to {{ relate }} within a {{ taxonomy:portals }} loop

So I'm starting to think maybe I'm not thinking about this correctly, and/or perhaps that it's not possible to filter with :is="" or {{ relate }} by slug because that value is not actually stored in the individual taxonomy yaml files but rather the filename itself?

Appreciate any help here!

Answered by JT!
>>>>>>> Answered <<<<<<<
4 Replies