All things Shopify and commerce
Anchor tags in nav not working. System changes "href" to "data-target" when #'s are used, not sure if that is part of the cause of the problem.
On this page: https://sunshieldplus.com/, you can see the Ingredients link has a "data-target" with the URL and #sectionID, standard anchor tag link added to the menu item. But it does not work.
Please help!
Tyler
Hello @tbenari ,
Make the data-target/href conditional
For homepage your value should be "#shopify-section-sections--16134179586134__newsletter"
and for inner pages it should be "shop-domain/#shopify-section-sections--16134179586134__newsletter"
There is no other issue in it.
Regards
Guleria
Thanks for your answer, though, unfortunately, your recommendation does not fix the issue. The need here may have been clouded by my use of the footer as my example URL for the nav item.
Can you share what you tried with the recommendations I shared?
If you make this navigation conditional it will work 100% btw I'm not sure how good you are with code because without that you cannot implement it.
And with data-target conditional I meant
For homepage data-target should be "#shopify-section-sections--16134179586134__newsletter"
and for inner pages it should be "shop-domain/#shopify-section-sections--16134179586134__newsletter"
Hmmm.. I was able to add Javascript to make the URL for nav items conditional based on the page the user is on, for both desktop and mobile navs.
But, for good usability, I need there to be a consistent animation of the page moving down to the intended section so the user knows they are still on the homepage. Can anyone help?
Any help there?
Yes please follow the example
https://css-tricks.com/snippets/jquery/smooth-scrolling/
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025