Disable Categories and Tags Pages in Hugo Website | ninjasquad
In this tutorial, we’ll learn how to disable taxonomy and term pages (such as Categories and Tags) in Hugo website.
When you generate a website using Hugo static site generator. Hugo automatically create taxonomies for
categories and generates the following pages by default:
- Taxonomy Pages for Categories
/tagswhich list out all the categories and tags of the website.
- Term Pages for Category e.g.
/categories/technologyand Tag e.g.
/tags/trendingwhich list out all the posts belongs to that category or tag.
You can disable the default behavior of generating taxonomy and term pages.
Disable Taxonomy and Term Pages
Now you know about taxonomy and term pages. There are two ways to disable them:
Disable using config.toml
This approach is recommended, when you want to disable taxonomy and term pages permanently everytime you build your website.
Add the “taxonomy” and “term” values to the
disableKinds configuration variable in your configuration file.
title = "Hugo example site" baseurl = "https://www.example.com" disableKinds = ["taxonomy", "term"] [taxonomies] category = "categories" tag = "tags"
Disable using command-line
This approach is recommended, when you want to disable taxonomy and term for a specific build of your website.
Execute following command from terminal to disable them:
To serve website in the localhost environment, execute following command:
hugo server --disableKinds=taxonomy,term