Is it possible to redirect /collections/ to /collection/all ?

cwilson
Shopify Partner
11 0 5

Hi,

 

Just wondering if it is possible to do this...

There aren't many products on the site I'm working on, so within the main navigation the 'STORE' links to /collections/all. 

The problem is that if someone visits mysite.com/collections - it takes them to an overview of all of the collections which I don't want. 

Is there a way to bypass this with redirects? 

 

Thanks 

Replies 11 (11)

Dirk
Shopify Staff
2217 247 506

Hey, @cwilson 

If you want your 'STORE' to link to all of the products available on your store as opposed to all of the collections on your store, you can make this change within your navigation settings.

By going to online store > navigation > click on the menu you want to edit > click the edit button beside menu item you want to edit >change the link to 'All Products'. As shown below:

 

 

Once you do that, be sure to save your changes. If there is anything else I can help you with, please let me know.

Dirk | Social Care @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

cwilson
Shopify Partner
11 0 5

Hi Dirk,

 

Thanks, but that isn't quite what I was looking for. Even though the navigation bar links to 'All Products' if a visitor was to navigate to www.mysite.com/collections/ they would still see a page that I don't want them to see.

I have no need for the page, so, therefore, do not want to spend time having to style it when it is redundant. 


Is there a way that I can redirect all traffic that tries to reach /collections/ ? 

 

Thanks 

rwchampin
Tourist
4 0 3

Did you ever get an answer to this?  Im not sure why all the Shopify members think a solution is to hide the links....people can still access the page.....google can still index them......

cwilson
Shopify Partner
11 0 5

Unfortunately not... 

alexfc
Shopify Partner
20 4 3

Hi, a bit late to the party 😀

I had the same request from a client. The Shopify redirects don't seem to work with some key pages, like the /collections one.

dehjkdgjhegfjhrtggjyhgjh4.jpg


I made it work by adding a JavaScript redirect in the list-collections.liquid template file in my theme:

<script>
  location.href = '/collections/all';
</script>

 

Hope this helps.

BoSand
Shopify Partner
1 0 0

Alex, where exactly would you add the script?

I tried adding at the end or before {% endschema %} of my collection-list.liquid or to list-collections.json - doesn't work, it won't redirect.

Thanks!

Deebella
Shopify Partner
16 0 4

Add the following script in the theme.liquid file before </body>

<script>
let url = window.location.href;
if (url.includes('/collections/collection-name')) {
location.href = '/products/productname';
}
</script>

diego_ezfy
Shopify Partner
2958 568 891

Yes, the following instructions will work for any theme.

1. In your Shopify Admin go to online store > themes > actions > edit code
2. In your theme.liquid file, find the </body> (press CTRL + F or command + F on Mac)
3. paste this code right above the </body> tag:

 

<script>
if (/collections$/.test(window.location.href)){
var url = `${window.location.href}/all` 
window.location.href = url;
}
</script>

 


Whenever the user lands on a URL ending specifically with "collections" they will be redirected to "collections/all".

Kind regards,
Diego

Virus47
Tourist
3 0 0

Hi Diego, this solution definitely helps when someone lands on <store>/collections. However, it does not help when someone adds the '/' at the end, e.g., <store>/collections/

dhendriksen
Excursionist
17 2 4

Hey @diego_ezfy , thank you for this. Do you have a solution for what happens when the client puts a / on the end? Your solution works for ABC.com/collections but not ABC.com/collections/

 

Thank you. Each of our collections represent products that are exclusive for a certain customer. We don't want people to get in a situation where they can see all of our collections. That would be bad.

benhu
Shopify Partner
2 0 2

Do something like following in your theme.liquid by adding a <script></script> block containing following,

 

 

// redirect '/collections' or '/collections/' or '/products' or '/products/' to '/pages/our-product-range'
// Shopify navigation redirects won't work for these urls as they are Shopify default urls not controlled by the theme
if (window.location.pathname === '/collections' || window.location.pathname === '/collections/' || window.location.pathname === '/products' || window.location.pathname === '/products/') {
window.location.href = '/pages/our-product-range';
}

 

 
In terms of SEO, before anyone asks,