hugo-theme-relearn/exampleSite/content/configuration/siteorganization/multilingual/_index.en.md
2024-10-11 16:47:18 +02:00

2.5 KiB

+++ description = "How to configure your site to be multilingual" title = "Multilingual" weight = 2 +++

The Relearn theme is compatible with Hugo's multilingual mode.

The theme supports a wide set of languages, also supporting languages written right to left.

{{% expand "Supported languages" %}}

  • Arabic
  • Simplified Chinese
  • Traditional Chinese
  • Czech
  • Dutch
  • English
  • Finnish
  • French
  • German
  • Hindi
  • Hungarian
  • Indonesian
  • Italian
  • Japanese
  • Korean
  • Polish
  • Portuguese
  • Romanian
  • Russian
  • Spanish
  • Swahili
  • Turkish
  • Vietnamese {{% /expand %}}

Basic Configuration

This example will show you, how to convert your site created in the Getting Started section to be multilingual using translation by file name. You can also use translation by content directory, but this is out of the scope of this documentation.

Define your languages in your hugo.toml file. For example with English and Piratish English website.

{{< multiconfig file=hugo >}} defaultContentLanguage = "en"

[languages] [languages.en] title = "My Website" weight = 1 languageName = "English"

[languages.pir] title = "Arrr, my Website" weight = 2 languageName = "Pirrratish" {{< /multiconfig >}}

Then, for each new page, append the id of the language to the file.

├── content
│   ├── basics
│   │   ├── first-content
|   |   |   ├── _index.en.md
|   |   |   └── _index.pir.md
│   │   ├── second-content
|   |   |   ├── _index.en.md
|   |   |   └── _index.pir.md
│   │   ├── third-content.en.md
│   │   └── third-content.pir.md
│   ├── _index.en.md
│   └── _index.pir.md
├── themes
│   └── hugo-theme-relearn
│       └── ...
└── hugo.toml

You may want to take a look into search configuration. It has some additional options for multilingual websites.

Disable Language Switching

Switching the language in the browser is a great feature, but for some reasons you may want to disable it.

Just set params.disableLanguageSwitchingButton=true in your hugo.toml

{{< multiconfig file=hugo >}} [params] disableLanguageSwitchingButton = true {{< /multiconfig >}}