Multilingual
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.
defaultContentLanguage: zh-cnCreate the translation configuration file
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: 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.
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.mdTranslation by Content Directory
Translation by content directory need to specify the content directory of translation:
languages:
en:
contentDir: content/english
languageName: English
weight: 10
zh-CN:
contentDir: content/zh-CN
languageName: 简体中文
weight: 20content/
├── 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.mdNote
By this way, the content directory has more level, see Hugo Documatation for more deatils.