Disable Categories and Tags Pages in Hugo Website
Disable Taxonomy and Term Pages in Hugo Website
In this tutorial, we’ll learn how to disable taxonomy and term pages (such as Categories and Tags) in Hugo website.
Overview
When you generate a website using Hugo static site generator. Hugo automatically create taxonomies for tags
and categories
and generates the following pages by default:
- Taxonomy Pages for Categories
/categories
and Tags/tags
which list out all the categories and tags of the website. - Term Pages for Category e.g.
/categories/technology
and Tag e.g./tags/trending
which 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.
config.toml
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:
hugo --disableKinds=taxonomy,term
To serve website in the localhost environment, execute following command:
hugo server --disableKinds=taxonomy,term