Hi, I’m building a multilingual site. Here the files I’m working on:
config.toml
...
# Disable errors in browser because of symlink error
# https://discourse.gohugo.io/t/symlinks-error-blocks-site-rendering-in-hugo-server-in-0-50/14962
disableBrowserError = true
#
# Multilingual
#
DefaultContentLanguage = "it"
[languages]
[languages.it]
languageName = "Italiano"
weight = 0
[languages.en]
languageName = "English"
weight = 1
content/contatti.it.md (italian is default language)
---
title: Contatti
---
content/contatti.en.md
---
title: Contact
slug: "contact" # rewriting the slug
---
themes/my-theme/layouts/index.html
...
<a href="{{ "contatti/" | relLangURL }}">{{ i18n "home" }}</a>
...
Now opening the site in italian I see the rendered link is:
<a href="/contatti/">Casa</a>
and in english it’s
<a href="/en/contatti/">Home</a>
while it should be (or I would be):
<a href="/en/contact/">Casa</a>
Someone can help me?
Thanks
We need a bit more info to be able to help you, so please have a look at Requesting Help and provide some more details? If you can provide a link to your repo that would be great, but at least I think it would be helpful to see your config
file. Thanks.
Hi Rick, I updated the first post adding info about the config file. At the moment I haven’t a repository. Let me know if you need other infos. Thanks
Hmm @dangelion, it looks correct. Try adding the slug
param to content/contatti.it.md
?
Tried but it’s the same. It renders the link as /en/contatti/
that gives a 404… in your projects instead it works as expected?
I haven’t tried localizing slugs yet, I’m afraid.
Your “contatti” character chain is hard coded… Not really nice.
Please have a look at Multilingual mode | Hugo
A testing (or Work in Progress) site I made: https://github.com/nfriedli/chez-olivia-et-pascal.ch/
Hi I have the same issue as dangelion.
Has someone found a solution?
It should be something quite common, right?
It looks like relLangURL simply prepends the language to the provided URL, and does not replace the slug if it has been overridden in the translated page.
I could not find other functions that behave smarter.
Many thanks!