I set up a page in our company with hugo. Since there are some employee from foreign countries some of the content must be translated to english.
There are 4 sections, each represented by a folder.
In each of these folders there is a _index.md
I used this approach: Single-Domain Bilingual Site 20180205
The config.toml
goes like this:
baseurl = "http://internal.address.tld"
languageCode = "de-DE"
uglyURLs = true
relativeURLs = true
canonifyURLs = false
theme = "own-theme"
PreserveTaxonomyNames = true
DefaultContentLanguage = "de"
[languages]
[languages.de]
languageName = "deutsch"
title = "klasdfklasf - Info-Seiten"
weight = 1
[languages.en]
languageName = "english"
title = "klsdfklsjkldf Info Site"
weight = 2
SectionPagesMenu = "main"
and then in each _index.md
I have a frontmatter like this:
+++
date = "2017-01-01"
title = "Aktuelle Kurznachrichten"
linktitle = "Blog"
description = "Das Blog enthält Beiträge zu allen Themen, die mehr oder weniger aktuellen Bezug haben. Die Beiträge sind zusätzlich auch thematisch geordnet"
[menu]
[menu.main]
name = "Blog"
url = "/blog.html"
weight = 10
+++
This works for the (default) German pages and builds a correct menu. Then I set up all the pages _index.en.md
in each of the sections like this
+++
date = "2017-01-01"
title = "Latest news in brief"
linktitle = "News"
description = "The blog contains articles on all topics that are more or less up to date. The contributions are also sorted by topic"
[menu]
[menu.main]
name = "News"
url = "/blog.html"
weight = 10
+++
and I got the correct menu in the German part of the homepage, but each menu entry appeared twice in the English part of the homepage in /en
, once with the english and once with the german title. Both were linked to the english content though.
I changed the frontmatter of the english files by adding an identifier:
+++
date = "2017-01-01"
title = "Latest news in brief"
linktitle = "News"
description = "The blog contains articles on all topics that are more or less up to date. The contributions are also sorted by topic"
[menu]
[menu.main]
name = "News"
identifier = "blog"
url = "/blog.html"
weight = 10
+++
and thus was able to have the menu entries only once in the english part of the homepage also.
But: Hugo (0.36) is complaining:
hugo server -w -D -F --disableFastRender
←[?25lBuilding sites . ERROR 2018/02/15 12:48:12 Two or more menu items have the same name/identifier in Menu "main": "section1".
Rename or set an unique identifier.
ERROR 2018/02/15 12:48:12 Two or more menu items have the same name/identifier in Menu "main": "section2".
Rename or set an unique identifier.
ERROR 2018/02/15 12:48:12 Two or more menu items have the same name/identifier in Menu "main": "section3".
Rename or set an unique identifier.
ERROR 2018/02/15 12:48:12 Two or more menu items have the same name/identifier in Menu "main": "blog".
Rename or set an unique identifier.
←[K25h
According to the docs Menu templates | Hugo
The identifier must match the section name.
I cannot change it’s value since english and german pages reside inside the same content subfolder = section.
After reading this Menus | Hugo I got the impression name
and identifier
are more or less the same so I changed the frontmatter again.
I thought I should change the name
variable to the correct section name - but nothing changed:
+++
date = "2017-01-01"
title = "Latest news in brief"
linktitle = "News"
description = "The blog contains articles on all topics that are more or less up to date. The contributions are also sorted by topic"
[menu]
[menu.main]
name = "blog"
url = "/blog.html"
weight = 10
+++
Hugo is still complaining about
ERROR 2018/02/15 16:37:57 Two or more menu items have the same name/identifier in Menu “main”:
I don’t really know how to solve this.
I also find the menu entries not sorted by weight according to the frontmatter, but alphabetically.