Can I redirect collections to a page in Shopify with Javascript?

Hello,

I know it’s not possible to add a redirect for /collections in the Shopify redirects.

However, would it still be possible to force a redirect (perhaps with Javascript)?
I like two of my /collections urls to redirect to a page.

For example

/collections/classics to /pages/classics

Thank you!

Hello,

Yes

it can be done by javascript.

But can you send me the store URL?

Yes I’ve sent you a pm!

Hi @Pura-web ,

This is Kate from PageFly - Landing page builder, I’d like to suggest this idea:
Step 1: Go to Online Store->Theme->Edit code
Step 2: Asset->/theme.liquid->Paste below code before in theme.liquid file:


I hope it would help you

This worked, thank you so much! Would it be possible that you don’t see the ‘in between’ page appearing? Now it goes to the original link first and then jumps to the new page. It happens fast, but it is still noticeable.

Hi @Pura-web ,

Thank you for responding. Since it is written in js, which js will load after the HTML, you feel like there will be something like that.
But I think it won’t affect much.

Best regards,

Kate | PageFly

This worked for me too, thank you for sharing!

I’m so glad to hear that @Emm_1 . Thank you for letting me know that my suggestion is helpful for other users in the community. :blush:

You can add the code inside . This way the JS will work before the page is fully loaded.

Hey this worked! I managed to redirect storename.com/collections → to another link.

How do I do the same but for redirecting storename.com/products → to a different link?

Thanks

thank you. THANK YOU!!!