Active class for translated menus

Since pageRef does not work with translated menus, is there a way to set an active class for these menus?

Yes, it does. Try it:

git clone --single-branch -b hugo-forum-topic-39415 https://github.com/jmooring/hugo-testing hugo-forum-topic-39415
cd hugo-forum-topic-39415
hugo server

I am using menu.lang.toml file to translate menus. But I get a weird issue where clicking on items defined with pageref in config and slug in frontmatter doesn’t work unless I change both instances to url. This happens in translated language when trying to click on the menu items. I am creating a test site to see if it behaves the same, but could you have any idea why this happens?

I am unable to reproduce the problem. I’ve updated the example, restructuring the site config and adding slugs to content.

git clone --single-branch -b hugo-forum-topic-39415 https://github.com/jmooring/hugo-testing hugo-forum-topic-39415
cd hugo-forum-topic-39415
hugo server

Here is my test site (I just put dummy content in DE folder). I noticed this issue the first time I tried multilingual site and I have had to convert slug to url.

https://gitlab.com/tut-hugo/test → 404

Sorry. I forgot Gitlab repos are private by default. Try now.

The pageRef menu property must be set to the content path, with or without the extension, not the URL.

[[menu.main]]
name = 'foo'
pageRef = '/posts/foo.md'
weight = 1

Please look at the example referenced in my previous response.

Yeah, that one. From the docs:

site.GetPage will be used to do the page lookup

No no no. Have you actually cloned and examined my example?

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