We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Setting Up Redirects for Main Link and Anchor Links

Setting Up Redirects for Main Link and Anchor Links

AlyssaCTB
Visitor
1 0 1

We want to set up unique redirects for both the main page URL (https://www.totalboat.com/pages/varnishing) and for all anchor links we have linking to different sections on the page (ex. - https://www.totalboat.com/pages/varnishing#finishes). However, we've encountered an issue in Shopify's native URL redirect tool that, once we set up a redirect for the root path, it won't allow us to create redirects for the anchor links due to their sharing a root path. What can be done to allow us to set up redirects for all anchor links unique from the root path URL?

Replies 2 (2)

IamAnthony001
Shopify Partner
3 0 0

Hello @AlyssaCTB 
Shopify considers anchor links the same as the root URL (/pages/varnishing) in its redirect system. Anchor links (#something) are not being sent to the server — they are processed on the client/browser side only. This is normal web behavior, not Shopify-specific. Shopify cannot provide individual redirects for anchor links — this is a web restriction. For constructing behavior from anchor links, you need JavaScript to be on the page itself. Or, split sections into separate pages and re-target them using Shopify's native feature. 

Let me know how you'd like to proceed and i can provide code or setup details.

ElijahStownton
Excursionist
39 0 5

A common workaround is to redirect to the main page and then use JavaScript to scroll to the anchor once the page loads. You can also adjust your theme code to recognize query parameters and convert them into anchor navigation, but that requires some custom coding.