Previously, we had a rough understanding of Hugo’s configuration structure, and then we will introduce how to configure multilingual sites.
Name | Description |
---|---|
defaultContentLanguage | The default site language. |
defaultContentLanguageInSubdir | Whether URLs for the default language contain language codes, eg /en . |
hugo.toml
1defaultContentLanguage = 'en'
2defaultContentLanguageInSubdir = true
hugo.yaml
1defaultContentLanguage: en
2defaultContentLanguageInSubdir: true
hugo.json
1{
2 "defaultContentLanguage": "en",
3 "defaultContentLanguageInSubdir": true
4}
Name | Description |
---|---|
languageName | Name |
languageDirection | Language direction, such as rlt . |
weight | Lower weight gets higher precedence. |
title | Site’s title. |
copyright | Site’s copyright. |
languages.toml
1[ar]
2 languageDirection = 'rtl'
3 languageName = 'العربية'
4 weight = 4
5[en]
6 languageName = 'English'
7 weight = 1
8[zh-hans]
9 languageName = '简体中文'
10 title = 'HB (Hugo Bootstrap) 框架'
11 weight = 2
languages.yaml
1ar:
2 languageDirection: rtl
3 languageName: العربية
4 weight: 4
5en:
6 languageName: English
7 weight: 1
8zh-hans:
9 languageName: 简体中文
10 title: HB (Hugo Bootstrap) 框架
11 weight: 2
languages.json
1{
2 "ar": {
3 "languageDirection": "rtl",
4 "languageName": "العربية",
5 "weight": 4
6 },
7 "en": {
8 "languageName": "English",
9 "weight": 1
10 },
11 "zh-hans": {
12 "languageName": "简体中文",
13 "title": "HB (Hugo Bootstrap) 框架",
14 "weight": 2
15 }
16}
You may want to configure some stuff for each language, such as description
, and to do this, simply create language-specific configuration files, such as:
Configuration | Description |
---|---|
menus.en.* | English site’s menus. |
params.en.* | English site’s params. |
menus.zh-hans.* | Chinese site’s menus. |
params.zh-hans.* | Chinese site’s params. |
Learn more on Hugo Multilingual Mode.