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: Arabic
  • de: German
  • en: English
  • es: Spanish
  • fr: French
  • it: Italian
  • ja: Japanese
  • ko: Korean
  • pt: Portuguese
  • ru: Russian
  • vi: Vietnamese
  • zh-cn: Simplified Chinese
  • zh-tw: Traditional Chinese

To set up a multilingual site, you first need to configure the default language in the site configuration.

hugo.yaml
1defaultContentLanguage: zh-cn
Click to expand and view more

Create the translation configuration file

languages.yaml
 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: 4
Click to expand and view more

Hugo 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.

YAML
 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.md
Click to expand and view more

Translation by Content Directory

Translation by content directory need to specify the content directory of translation:

languages.yaml
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
Click to expand and view more
YAML
 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.md
Click to expand and view more

Copyright Notice

Author: Hugo Narrow

Link: https://hugo-narrow-docs.vercel.app/docs/multilingual/

License: CC BY-NC-SA 4.0

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Please attribute the source, use non-commercially, and maintain the same license.

Start searching

Enter keywords to search articles

↑↓
ESC
⌘K Shortcut