Taxonomy Configuration

Contents â–¾

Taxonomies provide a powerful method for organizing and categorizing content in Hugo. The Sans theme supports Hugo’s flexible taxonomy system, allowing you to use default taxonomies or create custom classifications for your content.


Understanding Taxonomies

Taxonomies are classification systems that enable content grouping and relationship building. Hugo automatically handles taxonomy generation and page creation once configured.

Default Taxonomies

The theme includes three pre-configured taxonomies commonly used in content management:

TaxonomySingularPluralUse Case
TagstagtagsKeyword-based content classification
CategoriescategorycategoriesBroad content grouping
AuthorsauthorauthorsContent attribution and authorship tracking
Table: Default Taxonomy Types

Configuration

Basic Setup

Taxonomies are configured in the hugo.toml file. Navigate to the [taxonomies] section and specify your desired taxonomies:

TOML
1
2
3
4
[taxonomies]
  tag = "tags"
  category = "categories"
  author = "authors"

Configuration Syntax

ComponentDescriptionExample
Singular FormLeft side of assignmenttag, category, author
Plural FormRight side of assignmenttags, categories, authors
Formatsingular = "plural"tag = "tags"
Table: Taxonomy Configuration Syntax

Important: The singular form defines the taxonomy identifier used in front matter, while the plural form determines the URL structure and list page naming.


Custom Taxonomies

Creating Custom Taxonomies

The process of creating custom taxonomies follows the same logic as that of default taxonomies.

Syntax Pattern

TOML
1
2
[taxonomies]
  singular = "plural"

Custom Taxonomy Examples

TOML
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
[taxonomies]
  # Default taxonomies
  tag = "tags"
  category = "categories"
  author = "authors"
  
  # Custom taxonomies
  series = "series"
  topic = "topics"
  project = "projects"
  location = "locations"
  difficulty = "difficulties"

Using Taxonomies in Content

Front Matter Configuration

Once taxonomies are defined in hugo.toml, assign them to individual content files through front matter:

YAML
1
2
3
4
5
6
7
8
9
+++
title = "Understanding Taxonomies"
date = 2024-01-15
tags = ["hugo", "documentation", "taxonomies"]
categories = ["tutorials"]
authors = ["John Doe", "Jane Smith"]
series = ["Hugo Basics"]
topics = ["content-organization"]
+++

Multiple Values

Taxonomies accept multiple values, enabling comprehensive content classification:

YAML
1
2
3
tags = ["web-development", "hugo", "static-sites", "jamstack"]
categories = ["tutorials", "technical"]
authors = ["Author One", "Author Two"]

Single Value Taxonomies

For taxonomies requiring only one value per post:

YAML
1
2
difficulty = ["beginner"]
format = ["video"]

Taxonomy Page Generation

Hugo automatically generates several page types for each configured taxonomy:

Page TypeURL PatternDescription
Taxonomy List/tags/Lists all available tags
Taxonomy Terms/tags/hugo/Shows all posts tagged with 'hugo'
Taxonomy RSS/tags/index.xmlRSS feed for taxonomy
Taxonomy Terms RSS/tags/hugo/index.xmlRSS feed for specific term
Table: Auto-Generated Taxonomy Pages

URL Structure Examples

With the configuration tag = "tags" and series = "series":

TEXT
1
2
3
4
5
6
/tags/                    # All tags
/tags/hugo/              # Posts with tag "hugo"
/categories/             # All categories
/categories/tutorials/   # Posts in category "tutorials"
/series/                 # All series
/series/hugo-basics/     # Posts in series "hugo-basics"

Display Configuration

Taxonomy Visibility

Control taxonomy display in various contexts through the [posts] and [sections] configuration:

TOML
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
[posts]
  showTags = true
  showCategories = true
  showAuthors = true
  showTagCloud = false
  showCategoryCloud = false
  showAuthorCloud = false

[sections]
  showTags = false
  showCategories = false
  showAuthors = false

Advanced Configuration

Taxonomy Weight and Ordering

Control taxonomy display order through front matter weights:

YAML
1
2
3
4
5
6
+++
title = "Advanced Hugo"
categories = ["tutorials"]
tags = ["hugo", "advanced"]
tags_weight = 10  # Higher weight = appears first
+++

Preserving Taxonomy Case

By default, Hugo lowercases taxonomy values. To preserve case:

TOML
1
2
3
4
[taxonomies]
  tag = "tags"

preserveTaxonomyNames = true

Taxonomy Rename Process

To rename a taxonomy:

  1. Update hugo.toml configuration
  2. Update all content front matter
  3. Rebuild site to regenerate pages
  4. Implement 301 redirects for old URLs
  5. Update internal links and references