Multilingual
Hugo supports the creation of websites with multiple languages. In this post we will explain how to get configure Multilingual Mode with this theme.
You need to set a default language and configure at least two different languages used by your site to your configuration file at config.toml
:
defaultContentLanguage = "en"
[languages.en]
languageName = "English"
contentDir = "content/en"
weight = 10
[languages.de]
languageName = "German"
contentDir = "content/de"
weight = 20
To customize translation strings used by the theme you can create a file i18n/<languagecode>.toml
for every language you want to use e.g. i18n/en.toml
. You can lookup all used strings in the default translation file.
For the Bundle Menu as well as for the Extra Header Menu you can translate the name within the data file of the menu:
---
more:
# If `name` is a text, this text will be used as name for each language.
- name: News
ref: "/#"
icon: "gdoc_notification"
# To translate the name you can add a sub-item per language. Important: If you miss a language key
# that is configured in the languages list of your `config.toml` the name will be empty for this language!
- name:
en: Releases
de: Veröffentlichung
ref: "https://github.com/thegeeklab/hugo-geekdoc/releases"
external: true
icon: "gdoc_download"
To translate your content you need to create a directory content/<languagecode>/
for each language you want to use e.g. content/en/
. This language directories will hold the translated pages for the particular language.
If you have configured at least two different languages, the language switcher will be enabled in the UI automatically. The switcher is as part of the header menu and displayed on all pages.