Get URL with anchor

Hello. I am creating the menu and now I show to add a class “active” for the active point of the menu.
I have a condition

{{ if eq (.RelPermalink | relLangURL) (.link | relLangURL) }}

but it doesn’t include anchor. For example, my URL is /content/#block

.RelPermalink | relLangURL

will be /content/, but I need /content/#block

Is there are reason you are not using .IsMenuCurrent?
https://gohugo.io/templates/menu-templates/

This works with menu entries defined in front matter, and it works with menu entries defined in site configuration if you specify pageRef instead of url in your configuration.

In your example above, if .link represents the url property of the menu entry, strip the fragment before comparing.

I don’t create menu via config. I make it custom. Essentially, I need to check on a normal page whether the current page with the anchor is the one specified in the condition.

Then do this.

Can u help me?
This is the test repo - Bitbucket

Now two menus have class active.

image

Thank you for providing the test repository. I now understand what you are trying to do: add dynamic functionality to a static page. You’ll need some JavaScript for that, updating the class based on window.location.hash.

I don’t think it’s worth the effort or additional complexity.