You and I have discussed menu definition before:
https://discourse.gohugo.io/t/38727/2
- You can omit the
identifier
property unless two or more entries in a given language have the samename
property. - Use the
pageRef
property for internal links, and use theurl
property for external links. If you don’t do this, you will run into this issue. - Omit the language prefix (example:
/es
) when specifying thepageRef
property. You’ve defined the menu entries per language, so Hugo knows what to do.
With these changes, your site configuration should look like this:
config.toml
[languages.en]
contentDir = 'content/english'
description = 'Kaliriu in English'
languageCode = 'en-US'
languageName = 'English'
weight = 1
[[languages.en.menu.main]]
name = 'Home'
pageRef = '/'
weight = 1
[[languages.en.menu.main]]
name = 'Projects'
pageRef = '/projects'
weight = 2
[[languages.en.menu.main]]
name = 'Blog'
pageRef = '/blog'
weight = 3
[[languages.en.menu.main]]
name = 'Contact'
pageRef = '/contact'
weight = 4
[languages.es]
contentDir = 'content/spanish'
description = 'Kaliriu en Español'
languageCode = 'es-ES'
languageName = 'Español'
weight = 2
[[languages.es.menu.main]]
name = 'Inicio'
pageRef = '/'
weight = 1
[[languages.es.menu.main]]
name = 'Proyectos'
pageRef = '/projects'
weight = 2
[[languages.es.menu.main]]
name = 'Blog'
pageRef = '/blog'
weight = 3
[[languages.es.menu.main]]
name = 'Contacto'
pageRef = '/contact'
weight = 4
Finally, to allow your site to be served correctly from both kaliriu.netlify.app
and kaliriu.com
, do not pass the menu entry URL
through absLangURL
. Change this:
<a class="header-nav__list-link" href="{{ .URL | absLangURL }}">{{ .Name }}</a>
To this:
<a class="header-nav__list-link" href="{{ .URL }}">{{ .Name }}</a>