Hugo Multilingual Collection Translation: Solving the Language Switcher Issue With Different Display Names
Contents
The Problem
In FixIt theme, collections are a custom taxonomy. If Chinese and English posts use different collection names:
# zh-CN
collections: ["Quadlet 配置分享"]
# en
collections: ["Quadlet Config Sharing"]The language switcher on /collections/ pages and post pages disappears. Hugo treats them as two separate taxonomy terms, so .IsTranslated and .AllTranslations return nothing.
Currently using Hugo v0.160.1.
The Solution
The approach is straightforward: use the same collection name across all languages, and let _index.md provide localized display titles.
Take the quadlet-config-sharing collection as an example. Create:
content/collections/quadlet-config-sharing/
├── _index.zh-CN.md
└── _index.en.md_index.zh-CN.md:
---
title: "Quadlet 配置分享"
---_index.en.md:
---
title: "Quadlet Config Sharing"
---- Both languages share the URL
/collections/quadlet-config-sharing/(determined by the directory name) - The Chinese display name is “Quadlet 配置分享”
- The English display name is “Quadlet Config Sharing”
- No
translationKeyneeded - same term name, Hugo auto-links them
Post Configuration
Both language versions use the same collection name in frontmatter:
# xxx.en.md
collections: ["quadlet-config-sharing"]
# xxx.zh-CN.md
collections: ["quadlet-config-sharing"]That’s it. The language switcher will work normally across all collection pages and posts.