Taxonomy Configuration
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:
| Taxonomy | Singular | Plural | Use Case |
|---|---|---|---|
| Tags | tag | tags | Keyword-based content classification |
| Categories | category | categories | Broad content grouping |
| Authors | author | authors | Content attribution and authorship tracking |
Configuration
Basic Setup
Taxonomies are configured in the hugo.toml file. Navigate to the [taxonomies] section and specify your desired taxonomies:
| |
Configuration Syntax
| Component | Description | Example |
|---|---|---|
| Singular Form | Left side of assignment | tag, category, author |
| Plural Form | Right side of assignment | tags, categories, authors |
| Format | singular = "plural" | tag = "tags" |
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
| |
Custom Taxonomy Examples
| |
Using Taxonomies in Content
Front Matter Configuration
Once taxonomies are defined in hugo.toml, assign them to individual content files through front matter:
| |
Multiple Values
Taxonomies accept multiple values, enabling comprehensive content classification:
| |
Single Value Taxonomies
For taxonomies requiring only one value per post:
| |
Taxonomy Page Generation
Hugo automatically generates several page types for each configured taxonomy:
| Page Type | URL Pattern | Description |
|---|---|---|
| Taxonomy List | /tags/ | Lists all available tags |
| Taxonomy Terms | /tags/hugo/ | Shows all posts tagged with 'hugo' |
| Taxonomy RSS | /tags/index.xml | RSS feed for taxonomy |
| Taxonomy Terms RSS | /tags/hugo/index.xml | RSS feed for specific term |
URL Structure Examples
With the configuration tag = "tags" and series = "series":
| |
Display Configuration
Taxonomy Visibility
Control taxonomy display in various contexts through the [posts] and [sections] configuration:
| |
Advanced Configuration
Taxonomy Weight and Ordering
Control taxonomy display order through front matter weights:
| |
Preserving Taxonomy Case
By default, Hugo lowercases taxonomy values. To preserve case:
| |
Taxonomy Rename Process
To rename a taxonomy:
- Update
hugo.tomlconfiguration - Update all content front matter
- Rebuild site to regenerate pages
- Implement 301 redirects for old URLs
- Update internal links and references