I tried to find a theme that implements this correctly and also read the documentation, but couldn’t figure it out, sorry if it’s obvious.
Besides enabling the languages in
config.toml I have the following:
Any ideas / help / impulses? Thanks!
To me that sounds like you want to “localize permalinks”.
slug frontmatter parameter instead of
url. This one will only cover the current directory level, so /categories/_index.de.md gets
slug: kategorien and /categories/category1/_index.de.md gets
slug: kategorie1. The resulting link should be
Just tried that, it doesn’t work.
And also I want:
/kategorie/kategorie1 (singular) and
/kategorien/ (plural). Both are list pages of course. That’s why I use
With my current setup the english version works as expected, in the german version the sites get generated but no posts are listed with the corresponding categories.
I didn’t see the plural there…
I don’t think that’s possible with the built in l12n system. What you could do is putting the german files into a folder
kategorien and then employ the
url frontmatter to map the categories to
kategorie/kategorie1 and so on. You will have to find a way to set the language codes in the templates depending on what the categories folder name is. Maybe a bit too hacky.
I wonder what happens when you add
alias: kategorie to the parent german file.
Maybe it’s best if you have a repo to test around online somewhere.
Hmm, it seems like its working like I had it. My problem was: I’ve set in the frontmatter of the article itself
categories: - Kategorie1 instead of
categories: - Category1. I translated it there. Not sure if it really works. Will update here if there is another problem. Thanks @davidsneighbour for helping!
I think you are right there. A category/tag is only in the original the right one. The translation is for the URL, not the category. If you want to translate the category this is done with the
title frontmatter in the _index.de.md file.
Yes, did that, that’s the right way. The problem was I exported the articles / posts from WordPress and there (at least for the i18n plugin I used) every translation of a category was a category on its own. Hugo is a lot better in that sense (but didn’t think about in the first place). Thanks again!