Internationalization (i18n) Configuration
Hugo Narrow has excellent multilingual support. Currently supported languages include:
ar
: Arabicde
: Germanen
: Englishes
: Spanishfr
: Frenchit
: Italianja
: Japaneseko
: Koreanpt
: Portugueseru
: Russianvi
: Vietnamesezh-cn
: Simplified Chinesezh-tw
: Traditional Chinese
NOTE
Translations are generated by Agent.
Basic Language Configuration
Configure supported languages in hugo.yaml
:
yaml
# Basic language settings
languageCode: en-US
defaultContentLanguage: en
defaultContentLanguageInSubdir: false
# Language configuration - language switch button reads supported languages from here
languages:
en:
languageCode: en-US
languageName: "English"
weight: 1
zh-cn:
languageCode: zh-CN
languageName: "简体中文"
weight: 2
ja:
languageCode: ja-JP
languageName: "日本語"
weight: 3
fr:
languageCode: fr-FR
languageName: "Français"
weight: 4
Language Switch Configuration
yaml
params:
# Language switcher settings
showLanguageSwitch: true # Show language switcher
Multilingual Organization Methods
When configuring a multilingual site, please follow one of these two methods to structure your multilingual content.
Hugo supports two main methods for organizing multilingual files: Filename Translation and Directory Translation. Each method has its advantages and suitable use cases.
Method 1: Filename Translation
File Structure
content/
├── posts/
│ ├── my-first-post.md
│ ├── my-first-post.zh-cn.md
│ ├── my-first-post.ja.md
│ └── my-first-post.fr.md
├── about/
│ ├── _index.md
│ ├── _index.zh-cn.md
│ ├── _index.ja.md
│ └── _index.fr.md
└── _index.md
Method 2: Directory Translation
File Structure
content/
├── en/
│ ├── posts/
│ │ └── my-first-post.md
│ ├── about/
│ │ └── _index.md
│ └── _index.md
├── zh-cn/
│ ├── posts/
│ │ └── my-first-post.md
│ ├── about/
│ │ └── _index.md
│ └── _index.md
├── ja/
│ ├── posts/
│ │ └── my-first-post.md
│ ├── about/
│ │ └── _index.md
│ └── _index.md
└── fr/
├── posts/
│ └── my-first-post.md
├── about/
│ └── _index.md
└── _index.md