Basically a short summary of what I had to dig for in the process of giving this site a go.
A note: I prefer to use YAML for Hugo configuration because TOML is less useable for nested structures like menu configuration and JSON is a bit less human-readable in general. A default format for front matter of content created with hugo new command can be set by modifying the template archetypes/default.md.
-
Do a regular i18n setup in Hugo project configuration:
defaultContentLanguage: en defaultContentLanguageInSubdir: false params.displayFullLangName: falseparams.displayFullLangName: falsetells PaperMod theme to use capitalized 2-letter language ID as a language name in selector. -
Translate the main menu.
An example:
languages: en: weight: 10 languageName: English menu: main: - weight: 10 name: Posts pageRef: /posts - weight: 20 name: Tags pageRef: /tags - weight: 30 name: Categories pageRef: /categories - weight: 40 name: Search pageRef: /search ru: weight: 20 languageName: Русский menu: main: - weight: 10 name: Посты title: Посты pageRef: /posts - weight: 20 name: Теги title: Теги url: /tags - weight: 30 name: Категории title: Категории pageRef: /categories - weight: 40 name: Поиск title: Поиск pageRef: /search -
Add JSON to generated output to make the search able to work:
outputs: home: [HTML, RSS, JSON] -
Add a translation for «Posts» page: create
content/_index.<language ID>.mdand put a translation of the word «posts» intotitlefield of the front matter.An example:
content/_index.ru.md--- title: Посты --- -
Add «Search» page
content/search.mdand its translation(s) namedcontent/search.<language ID>.md.An example:
content/search.md:--- title: Search layout: search summary: Search placeholder: Search the site ---content/search.ru.md:--- title: Поиск layout: search summary: Страница поиска по сайту placeholder: Поиск по сайту --- -
Add translations for blog utility pages i. e. «Tags», «Categories» and «Search»: create
content/categories.<language ID>.md,content/tags.<language ID>.mdandcontent/search.<language ID>.md. Basically a front matter with onlytitlefield is enough. -
Add posts in default language named like
posts/some-new-post.mdand corresponding translations named likeposts/some-new-post.<language ID>.md.