Change the url of 2 different folders in multiple languages without changing their names

I open a new folder in the content folder, let’s say “learn”.

Then I start entering my content under the “learn” folder and add “_index.md” inside this folder.

I open a “learn” folder under the “Layouts” folder and create my designs and when I enter the url “example.org/learn/” I get the result I want.

But I know that even if I add a slug value to the “_index.md” file under the “learn” folder, I cannot change the url, it is not possible.

I just wanted to explain so far, my main question is this:

I will use the “learn” folder in multiple languages and the url of this folder is “example.org/learn/”. I want to change this url to another language. If I make the folder name different, the multilingual structure cannot detect it. If I make the same name, I will not be able to change the url in the other language.

Which way can I solve this problem?

Assuming you are translating either by filename or content directory, use url instead of slug.

title: Lorem ipsum
url: "url-here"
---

@ardacarofficial see this edited answer based on Joe’s clarification below.

1 Like

I don’t know this parameter you are great you solved a big problem of mine thank you <3

If you omit the leading slash, it will be language specific.

https://gohugo.io/content-management/urls/#set-url-in-front-matter

From Hugo 0.55, you can use URLs relative to the current site context (the language), which makes it simpler to maintain.

3 Likes

I didn’t know that! I have already translated like 100 pages and added the language prefix because I thought it is required (and because now I realize the leading slash was the cause of the URLs not working for translated pages)/

1 Like

See Multilingual mode | Hugo

If using url, remember to include the language part as well: /fr/compagnie/a-propos/.

1 Like

I removed the outdated information.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.