Content in multiple languages


#1

Hello there!

I have a multi-language site set up with two languages where the file names determine the language (ie “content/articles/name.en.md” and “content/articles/name.sv.md”).

Now I’m trying to generate two languages from one content file. I want to only have one content file (“content/products/product01.md”) but two paths: www.website.com/en/products/product01 and www.website.com/products/product01.

The reason being that the content file (product01.md) only contains front-matter data that does not need to be translated. I don’t want to have duplicates of the content files since it would be too much work and hard to update.

Is there any way to do this with Hugo?


#2

Have you tried using an alias in your front matter?


#3

Good suggestion! However, that results in a redirect to the original content in the original language, thus leaving the page in the original language instead of the desired language.

I have translations for the static strings in the template rendering the content, so the site needs to “be in correct language” (ie. you have to stay on /en/products/…) for it to work.


#4

Is it an option to use a data file that both the EN and SV translated files pull their data from? Because from what I understand, you don’t really want to use /products/product01 as a webpage, right?


#5

Hmm, probably not since I actually do want /producs/product01 as a page. Also, I’m using forestry.io to manage the contents, so data files would probably be more of a hassle.