In Configuration Structure, we have a clear understanding of configuration, and then we will introduce how to configure languages for 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 = 'Hugo Bootstrap 框架 (HB)'
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: Hugo Bootstrap 框架 (HB)
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": "Hugo Bootstrap 框架 (HB)",
14 "weight": 2
15 }
16}
Usually we configure site parameters and menus 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. |
For more details, please refer to Hugo Multilingual Mode.