Contents

Multilingual sites in Hugo

Multilingual sites in Hugo

How fast can you translate a web site? Of course it depends on a numbers of things. However, I wanted to test how long would it take to add a new language to a Hugo site (I picked Italian) and to translate the whole site, including 9 posts, the about page and the menu. It can be done in about 1 hour - 1 hour 30 minutes. After that, for each article, you also have to provide the translated version, and you can do that at your leisure. In fact, the two langage versions can be out of sync, or contain totally different topics, this is your choice.

Steps:

Declare a new language in your site’s config.toml.

[languages.it]
    weight = 1
    languageName = "Italian"
    contentDir = "content/italian"

For that language, define the parameters adding a specific section and translating all parameters.

[languages.it.params]
    title = "Briciole Digitali..."
    authorinfo = "<h4>Amministrato da Anto</h4>"
    ...

Translate also the main menu, item by item :

[[languages.it.menu.main]]
    name = "Informazioni"
    url = "/it/informazioni/"
    weight = 2
[[languages.it.menu.main]]
    name = "Categorie"
    url = "/it/categorie/"
    weight = 3
[[languages.it.menu.main]]
    name = "Etichette"
    url = "/it/etichette/"
    weight = 4

[[languages.it.menu.main]]
    name = "Tutti gli articoli"
    url = "/it/allposts/"
    weight = 5

[[languages.it.menu.main]]
    name = "English"
    url = "/"
    weight = 6

Then you make a copy of all the articles you want to translate under your content/italian folder, keeping the same structure as per your original site… and voilà!

Caution!

The fact that this can work or not may depend on the template. With the template I have been used it works like a song!


author

Authored By Anto

Anto likes to learn. This website was produced while learning Hugo. This and all other articles here are licensed under a Creative Commons Attribution 4.0 International License.

This website uses cookies to ensure you get the best experience on our website. Learn more Got it