Liquid, JavaScript, themes, sales channels
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!
Solved! Go to the solution
This is an accepted solution.
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 </body> in theme.liquid file:
<script>
let url = window.location.href;
if (url.includes('/collections/classics')) {
location.href = '/pages/classics';
}
if (url.includes('/collections/collection-2')) {
location.href = '/pages/collection-2';
}
</script>
I hope it would help you
Please let me know if it works by giving it a Like or marking it as a solution!
PageFly - #1 Page Builder for Shopify merchants.
All features are available from Free plan. Live Chat Support is available 24/7.
Hello,
Yes
it can be done by javascript.
But can you send me the store URL?
Yes I’ve sent you a pm!
This is an accepted solution.
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 </body> in theme.liquid file:
<script>
let url = window.location.href;
if (url.includes('/collections/classics')) {
location.href = '/pages/classics';
}
if (url.includes('/collections/collection-2')) {
location.href = '/pages/collection-2';
}
</script>
I hope it would help you
Please let me know if it works by giving it a Like or marking it as a solution!
PageFly - #1 Page Builder for Shopify merchants.
All features are available from Free plan. Live Chat Support is available 24/7.
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
Please let me know if it works by giving it a Like or marking it as a solution!
PageFly - #1 Page Builder for Shopify merchants.
All features are available from Free plan. Live Chat Support is available 24/7.
You can add the code inside <head> </head>. This way the JS will work before the page is fully loaded.
This worked for me too, thank you for sharing!
I'm so glad to hear that @Emm_ . Thank you for letting me know that my suggestion is helpful for other users in the community. 😊
Please let me know if it works by giving it a Like or marking it as a solution!
PageFly - #1 Page Builder for Shopify merchants.
All features are available from Free plan. Live Chat Support is available 24/7.
User | RANK |
---|---|
37 | |
29 | |
12 | |
12 | |
8 |
On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023You've downloaded the Search & Discovery app from the Shopify App store, and as you're ...
By Skye Nov 8, 2023The year-end shopping season is just around the corner. Is a flash sale on your radar? Are...
By Jasonh Nov 6, 2023