Multilingual permalinks with relLangURL and custom slug

#1

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

#2

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.

#3

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

#4

Hmm @dangelion, it looks correct. Try adding the slug param to content/contatti.it.md?

#5

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?

#6

I haven’t tried localizing slugs yet, I’m afraid.

#7

Your “contatti” character chain is hard coded… Not really nice.
Please have a look at https://gohugo.io/content-management/multilingual/#list-all-available-languages

A testing (or Work in Progress) site I made: https://github.com/nfriedli/chez-olivia-et-pascal.ch/