Products vs Collections urls

Solved
aviannah987
New Member
1 0 2

I'm seeing the following;

  • When navigating to a Product from a Collections page the Product page is displayed as .com/collections/collection-name/products/product-name
  • Looking at the Canonical link on that page it points to the true product page - .com/products/product-name

My question is, as our products only belong to one collection, is there a way to make the Product shown in the collection page link directly through the Collection page?

i.e. It looks the same however the products displayed link to - .com/products/product-name rather than .com/collections/collection-name/products/product-name

 

The reason I ask is that from an SEO point of view the internal linking from the collections pages point to the /collections/ URL which is then canonically redirected to /products/ which adds time to crawling the site as well as loses link equity through the redirect.

 

Accepted Solution (1)

Accepted Solutions
Fayyaz_Ahmed
Shopify Partner
176 34 64

This is an accepted solution.

Hello Aviannah:
This is a great question. Unfortunately, it's not something that is able to be changed. Only handles are able to be adjusted. So you could change what the URL displays the product name to be, but the Shopify generated URLs will stay the same. 



 

 

11-41-m0jmk-1ewsk.jpg11-42-5nuke-4vhus.jpg

Basically, the URL is like breadcrumb navigation. Whatever the route that it takes to get to a product will be shown in the URL. So, in this case, the product was in the collection so it will show /collection/collection-name/products/product-name. 

i hope that helped to clarify for you 🙂

Problem Solved? ✔️Accept the solution so you can help others.
* Email: fayyazraza@gmail.com * Skype: fayyaz_raza

View solution in original post

Replies 38 (38)
Tejas_Nadpara
Shopify Partner
1087 216 529

@aviannah987 

 

Replace the product.url in your collections template or other templates where collection product links are used.

{{ product.url | within: collection }}

and replace with

{{ product.url }}

 

for example:

product-url.png

 

 

Cheers,

Tejas

 

Shopify Expert | Skype: tejas.nadpara
- Like and Mark as an Accepted Solution if reply helpful
- Feel free to contact me on support@hexaecommerce.com regarding any help
Fayyaz_Ahmed
Shopify Partner
176 34 64

This is an accepted solution.

Hello Aviannah:
This is a great question. Unfortunately, it's not something that is able to be changed. Only handles are able to be adjusted. So you could change what the URL displays the product name to be, but the Shopify generated URLs will stay the same. 



 

 

11-41-m0jmk-1ewsk.jpg11-42-5nuke-4vhus.jpg

Basically, the URL is like breadcrumb navigation. Whatever the route that it takes to get to a product will be shown in the URL. So, in this case, the product was in the collection so it will show /collection/collection-name/products/product-name. 

i hope that helped to clarify for you 🙂

Problem Solved? ✔️Accept the solution so you can help others.
* Email: fayyazraza@gmail.com * Skype: fayyaz_raza
ANAND11
Excursionist
14 1 1

Thank You @Tejas_Nadpara 

This was very useful as I am having the same issue.

sylvie_n
Excursionist
15 0 3

Hi Tejas,

 

I am trying to achieve the same thing, but cannot find any reference to 'within: collection' in any of the collection template files.

Any clues on where else I can look?
The theme is debut

 

Many thanks,

Sylvia

Tejas_Nadpara
Shopify Partner
1087 216 529

@sylvie_n 

 

It would be in "product-card-grid.liquid" file.

 

Thank you,

Tejas

Shopify Expert | Skype: tejas.nadpara
- Like and Mark as an Accepted Solution if reply helpful
- Feel free to contact me on support@hexaecommerce.com regarding any help
sylvie_n
Excursionist
15 0 3

Hi Tejas,

 

Thank you for your quick reply. This file doesn't seem to exist on our theme.

Please see screenshots:

Screen Shot 2019-08-21 at 15.20.32.pngScreen Shot 2019-08-21 at 15.20.41.png

sylvie_n
Excursionist
15 0 3

Sorry, my mistake, I've found.

That worked - thank you so much!!

s3any
New Member
2 0 0

Hey guys, I am using Brooklyn theme, can you tell me which .liquid file can I locate this string?

 

thanks,

Sean

s3any
New Member
2 0 0

Found it .. it is within Product-grid-item.liquid🤙

Mike50
Excursionist
15 0 7

Hi there - appreciate the info but this solution is basically saying there is no solution.

Has anyone found a solution for this?  It's VERY important for SEO that the indexed product URL produces a page that includes a link to a designated main collection in the breadcrumbs.  Otherwise, the collection pages don't rank as well as they should, and the breadcrumb for the collections cannot be marked-up with schema to appear in SERPs.  This is why it's not a good practice to base breadcrumbs on the URL.  Collections should be assigned to products, not products assigned to collections, so now we have a potential deal-breaker for us and Shopify.

 

As I see it, there might be a work-around to this:  I noticed the canonical on product pages is set to the /product/ path like this:

https://www.bootycocktails.com/products/discolite-808-light-up-stripper-shoes-by-pleaser-shoes

...but, we would prefer to have the canonical set to the URL that includes a primary collection, like this:

https://www.bootycocktails.com/collections/light-up-stripper-shoes/products/discolite-808-light-up-s...

 

In that way, the page that includes the breadcrumb we want indexed will be included, it will appear in SERPs with schema markup, and Google will see the internal link to the desired "parent" collection.

 

Any way to do this in Shopify, or should I just give up?

 

Thank you!

Mike50
Excursionist
15 0 7

Might have found a canonical tag solution for this:

https://community.shopify.com/c/Shopify-Design/How-can-I-change-the-canonical-tags-on-my-website-pag...

 

I'll post how it works out.

JRC91
New Member
2 0 0

Hi Mike, 

 

Did you have any success?

 

Cheers,

Jake

Lael_Uberuaga-R
New Member
2 0 0

Hey @Mike50 , I think you might be able to do the reverse of what @Tejas_Nadpara said on the first page of this thread.

 

**NOTE: I am a fairly new Shopify partner (I started so I could do some front-end dev on my own company's store), so please back up / establish version control first if you decide to try my below advice. I'm not an expert yet. ****

 

So, I'm trying to do the exact opposite as you (route my product URLS as /products/xyz-product instead of /collections/abc-collection/products/xyz-product), because I'm trying to preserve link equity and not split the measured traffic in Google Analytics. So,  I  applied Tejas' advice of replacing the product.url in the various templates where it appears.

 

I wanted to REMOVE the collection routing, so I found instances of this in my collections templates:

{{ product.url | within: collection }}

and replaced that with this:

{{ product.url }}

 

and it worked like a charm.

 

I wonder if, since you want to ADD the collection routing, you could do the opposite, and find instances of the following syntax in your various pages:

{{ product.url }}

and replace it with this:

{{ product.url | within: collection }}

 

It's worth a shot! And if that doesn't do it you can always roll it back.

Mike50
Excursionist
15 0 7

Yeah, I ended up keeping the canonicals as-is because they would cause other issues when items were added to multiple categories (no way to control which category was "canonical"), so just ended up adding breadcrumbs to the template.  It's pretty much a hack-job, but a put a bunch of if/then's checking for up to 4 categories then just stringing them together as breadcrumbs along with structured data markup.  So far so good, but I would never recommend my coding style!  LOL!

 

Thanks for the help.

Lael_Uberuaga-R
New Member
2 0 0

Ah, that makes sense.  I'll have to keep that in mind when/if we create more than one collection because we will probably run into the same issue as you did. Glad you found a solution that works so far! 👍

Loom_Solar
New Member
1 0 0

Hey Tejas, Our shopify store is using empire theme. 

I do not see, these codes in collection template.  How this will be done?

 

Capture.PNG

dhanak
New Member
6 0 0

Hi Tejas

I am using Debut theme and I cant seem to find this in any file...

 

{{ product.url | within: collection }}

 

Any idea which file I would find this in?

Tejas_Nadpara
Shopify Partner
1087 216 529

@dhanak 

 

I would be in "product-card-grid.liquid" file.

Shopify Expert | Skype: tejas.nadpara
- Like and Mark as an Accepted Solution if reply helpful
- Feel free to contact me on support@hexaecommerce.com regarding any help
dhanak
New Member
6 0 0

That worked. Thanks!


@Tejas_Nadpara wrote:

@dhanak 

 

I would be in "product-card-grid.liquid" file.