Hugo Narrow supports the multilingual sites, with a toggle button available in the navigation bar for language switching.
Currently, Hugo Narrow supports the following languages:
ar: Arabicde: Germanen: Englishes: Spanishfr: Frenchit: Italianja: Japaneseko: Koreanpt: Portugueseru: Russianvi: Vietnamesezh-cn: Simplified Chinesezh-tw: Traditional Chinese
Note
The translation is generated by AI. Feel free to open an issue or submit a PR if you wish to add to or refine the translation.
To set up a multilingual site, you first need to configure the default language in the site configuration.
1defaultContentLanguage: zh-cnCreate the translation configuration file
1en:
2 languageCode: en-US
3 languageName: "English"
4 weight: 1
5
6zh-cn:
7 languageCode: zh-CN
8 languageName: "简体中文"
9 weight: 2
10
11ja:
12 languageCode: ja-JP
13 languageName: "日本語"
14 weight: 3
15
16fr:
17 languageCode: fr-FR
18 languageName: "Français"
19 weight: 4Hugo supports two primary approaches to organizing multilingual files: file name translation and directory translation. Each approach has its own advantages and applicable scenarios.
Translation by File Name
If you have an article named content/posts/my-first-post.md, you can specify a language suffix before the file extension to create content/posts/my-first-post.zh-cn.md as its Simplified Chinese translation.
1content/
2├── posts/
3│ ├── my-first-post.md
4│ ├── my-first-post.zh-cn.md
5│ ├── my-first-post.ja.md
6│ └── my-first-post.fr.md
7├── about/
8│ ├── _index.md
9│ ├── _index.zh-cn.md
10│ ├── _index.ja.md
11│ └── _index.fr.md
12└── _index.mdTranslation by Content Directory
Translation by content directory need to specify the content directory of translation:
1languages:
2 en:
3 contentDir: content/english
4 languageName: English
5 weight: 10
6 zh-CN:
7 contentDir: content/zh-CN
8 languageName: 简体中文
9 weight: 20 1content/
2├── en/
3│ ├── posts/
4│ │ └── my-first-post.md
5│ ├── about/
6│ │ └── _index.md
7│ └── _index.md
8├── zh-cn/
9│ ├── posts/
10│ │ └── my-first-post.md
11│ ├── about/
12│ │ └── _index.md
13│ └── _index.md
14├── ja/
15│ ├── posts/
16│ │ └── my-first-post.md
17│ ├── about/
18│ │ └── _index.md
19│ └── _index.md
20└── fr/
21├── posts/
22│ └── my-first-post.md
23├── about/
24│ └── _index.md
25└── _index.mdNote
By this way, the content directory has more level, see Hugo Documatation for more deatils.