Re: Link active class is not working.

Why isn't my link active class functioning on my store blog page?

sakinur-rahman
Shopify Partner
139 17 22

I have added a menu on my store blog page. And I am using this condition to add a css class. But it's not working. Please see the screenshoot.

<a class="{% if link.active %}site-nav--active{% endif %}" href="{{ link.url }}">
{{ link.title }}
</a>

 

Page link here: https://neophytofoods.com/blogs/recipes

Screenshot_320.pngScreenshot_319.png

Need a Shopify developer? Chat on WhatsApp


- For Shopify Design Changes | Shopify Custom Coding | Custom Modifications -

Your Coffee Tip and my code, A perfect blend. ❤️ Buy Me A Coffee


Website: HelloSakin.com
Replies 4 (4)

KLGeiger
Shopify Partner
13 0 8

Did you find a solution? I'm having the same issue.

Not every thing is #000000 and #ffffff

Ahmed_Afifi
Shopify Partner
2 0 1

This is quite annoying issue, but the solution is very simple, all you have to do, is to make sure the menu link assigned in the navigation settings, is not absolute link that copied/pasted, but make sure to search for the page/product/collection.. and select the object you are after from the link search there, this way shopify can deal with the link as object and then the active attribute will work properly.

what_ever
Excursionist
15 0 4

Thank you Ahmed!

Ahmed_Afifi
Shopify Partner
2 0 1

Welcome, glad i could help!