404 on missing term

Everything works as expected but is there a way to avoid a 404 and for me to display a message when there are no terms in a particular category?

I created a category called regions and created some 10 regions. Tours that take place in a region are properly displayed by /layouts/taxonomy/region.html. For those regions where I do not as yet offer any tours I get a 404 as expected. I therefore would like a way for me to indicate that no tours are offered in a particular region (rather than a 404) like modifying a 404 depending on the page?

You can force a page to exist at that address by creating it at content/taxonomy/region.md. That should work I guess.

1 Like

You can create taxonomy and term pages and add logic to handle when there are no Pages related to the specific term: https://gohugo.io/content-management/taxonomies/#add-custom-metadata-a-taxonomy-or-term


Thanks guys for pointing me in the right direction!

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