Translated taxonomies not including the /lang/ folder in its URL?

Hi again. I just noticed that the URL generated by translated taxonomies does not include the language folder as defined in the config.toml file.

In config.toml:

[language.lang_code.taxonomies]
  kategorya = "mga kategorya"
  tag = "mga tag"

In /content/en/categories/cat1/_index.md

+++
title = "Cat1"
aliases = ["category1"]
slug = "cat1"
translationKey = "cat1"
+++

In /content/fil/mga-kategorya/kat1/_index.md

+++
title = "Kat1"
aliases = ["kategorya1"]
slug = "kat1"
translationKey = "cat1"
+++

Once generated, the taxonomy links are as follows:
In the default en language:

  • Generated: domain.tld/categories/cat1/content.md

In the fil language:

  • Generated: domain.tld/mga%20kategorya/kat1/content.md == 404 error
  • Should be: domain.tld/fil/mga%20kategorya/kat1/content.md

Did I misunderstand how to use _index.md? Or is this a bug?

The workaround I found was to create a redirect alias. But in security-oriented browsers like Firefox, HTML redirect is blocked by default, the end-user have to click “Allow”–which confuses most visitors, so it’s preferable to avoid this workaround.

If taxonomies can be translated via config file but it’s not taking the /lang/ folder in its path during generation, how do we use translated taxonomies? I’m thinking I misunderstood something somewhere.

Thank you again.

EDIT:
Another unfortunate thing about the workaround I mentioned above, one has to add a redirect alias for every new term.

taxonomies get urlized, so your url would be mga-kategorya, not mga%20kategorya: https://gohugo.io/functions/urlize/

I’m not sure what you mean here, do you get md files generated?

It would be easier to help you if you have your code in a repo somewhere we can have a look at.

Hmm… this is weird then. When I run hugo server the URL used comes from this:

[language.lang_code.taxonomies]
  kategorya = "mga kategorya"
  tag = "mga tag"

So it becomes, for example: /mga kategorya/

The md files are generated and the link to it from a list is correct. However, the links generated for the category or tag is wrong.

Ahh, Apologies, there should be no “content.md” in the example above. Should be this way:

  • Generated: domain.tld/mga%20kategorya/kat1/ == 404 error
  • Should be: domain.tld/fil/mga%20kategorya/kat1/

I’ll see what I can do tomorrow. :slight_smile:

Just an update.

I figured out this one. It appears that this is theme based. The first theme I tried was multilingual ready and I automatically assumed every other theme are especially if these were recently updated.

I updated the relevant partial files to be absLangURL (since the theme by is using absURL) and also added urlize where needed.

After this URLs for the taxonomies are now correct.

Thanks!

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