跳转到内容

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.

The interface language controls site text that isn’t part of your content (e.g., “Read More”, “Next Page”).

  1. Configure Languages: Edit config/_default/languages.yaml to define which languages your site supports.
  2. Set Default: In hugo.yaml, set defaultContentLanguage to your primary language code (e.g., en, zh, es).

You can modify existing translations or create new language packs.

  1. Create the i18n Folder Create an i18n folder at your site root.

  2. Download or Create a File Download a language file (e.g., en.yaml) and save it to i18n/.

    • 文件夹i18n/
      • en.yaml
      • zh.yaml
  3. Edit Translations Open the YAML file and modify the text strings.

Serve your content in multiple languages.

Organize your content/ folder using language codes.

  • 文件夹content/
    • 文件夹en/
      • _index.md
      • 文件夹posts/
        • my-post.md
    • 文件夹zh/
      • _index.md
      • 文件夹posts/
        • my-post.md
  1. Migrate Existing Content Move your default content into a subfolder named after its language code (e.g., content/en/).

  2. Create Translations Create parallel folders for other languages (e.g., content/zh/) and add translated Markdown files.

  3. Configure Content Directories Update config/_default/languages.yaml to map each language to its content directory.

You can create separate menus for each language.

  1. Default Menu: config/_default/menu.yaml
  2. Translated Menus: Create files like menu.zh.yaml or menu.es.yaml.

When a user switches languages, the corresponding menu will be displayed automatically.