Multilingual & Internationalization (i18n)
此内容尚不支持你的语言。
Create a truly global site by customizing the interface language or translating your content into multiple languages. HugoBlox supports 35+ languages out of the box.
Interface Language
Section titled “Interface Language”The interface language controls site text that isn’t part of your content (e.g., “Read More”, “Next Page”).
Setting the Language
Section titled “Setting the Language”- Configure Languages: Edit
config/_default/languages.yamlto define which languages your site supports. - Set Default: In
hugo.yaml, setdefaultContentLanguageto your primary language code (e.g.,en,zh,es).
Customizing Translations
Section titled “Customizing Translations”You can modify existing translations or create new language packs.
-
Create the i18n Folder Create an
i18nfolder at your site root. -
Download or Create a File Download a language file (e.g.,
en.yaml) and save it toi18n/.文件夹i18n/
- en.yaml
- zh.yaml
-
Edit Translations Open the YAML file and modify the text strings.
Multilingual Content
Section titled “Multilingual Content”Serve your content in multiple languages.
Directory Structure
Section titled “Directory Structure”Organize your content/ folder using language codes.
文件夹content/
文件夹en/
- _index.md
文件夹posts/
- my-post.md
文件夹zh/
- _index.md
文件夹posts/
- my-post.md
-
Migrate Existing Content Move your default content into a subfolder named after its language code (e.g.,
content/en/). -
Create Translations Create parallel folders for other languages (e.g.,
content/zh/) and add translated Markdown files. -
Configure Content Directories Update
config/_default/languages.yamlto map each language to its content directory.
Multilingual Menus
Section titled “Multilingual Menus”You can create separate menus for each language.
- Default Menu:
config/_default/menu.yaml - Translated Menus: Create files like
menu.zh.yamlormenu.es.yaml.
When a user switches languages, the corresponding menu will be displayed automatically.