Redirect collection to page

Solved
Pura-web
Tourist
7 0 1

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!

Accepted Solution (1)
PageFly-Kate
Shopify Partner
823 278 236

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>

PageFlyKate_0-1675177651893.png

 

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.

View solution in original post

Replies 8 (8)
Angel95
Pathfinder
101 6 8

Hello,

 

Yes 

it can be done by javascript.

 

But can you send me the store URL?

banned
Pura-web
Tourist
7 0 1

Yes I’ve sent you a pm!

PageFly-Kate
Shopify Partner
823 278 236

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>

PageFlyKate_0-1675177651893.png

 

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.

Pura-web
Tourist
7 0 1

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.

PageFly-Kate
Shopify Partner
823 278 236

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.

KorayDundar
Visitor
1 0 0

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

Emm_
Shopify Partner
4 0 5

This worked for me too, thank you for sharing!

PageFly-Kate
Shopify Partner
823 278 236

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.