Re: Products vs Collections urls

Solved

How to link products directly from collection pages for better SEO?

aviannah987
Visitor
1 0 5

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)

Fayyaz_Ahmed
Shopify Partner
176 34 65

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 44 (44)

Tejas_Nadpara
Shopify Partner
1120 222 553

@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 tejas.nadpara@gmail.com regarding any help
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
1120 222 553

@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 tejas.nadpara@gmail.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
Visitor
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
Visitor
2 0 0

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

valleplateado
Tourist
6 0 1

Depends on your theme,  mine was in:
product-item.liquid

Loom_Solar
Visitor
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
Tourist
6 0 1

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
1120 222 553

@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 tejas.nadpara@gmail.com regarding any help
dhanak
Tourist
6 0 1

That worked. Thanks!


@Tejas_Nadpara wrote:

@dhanak 

 

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


 

Manuelgou
Shopify Partner
12 0 1

Hi Tejas,

Do you know where this code is located in the responsive theme from out of the sand box? 

 

Thanks in advance. 

BBbysds
Visitor
2 0 0

Hi Tejas,

I am using a Supply theme, in which template do i need to change the code.

Thanks and Regards

BBbySDS

Tejas_Nadpara
Shopify Partner
1120 222 553

@BBbysds 

 

You need to change in Supply theme Snippets > product-grid-item.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 tejas.nadpara@gmail.com regarding any help
BBbysds
Visitor
2 0 0

Hi Tejas,  Thanks it worked.

Thanks and Regards

BBbySDS

Manuelgou
Shopify Partner
12 0 1

Hi Tejas,

Do you know where this code is located in the responsive theme from out of the sand box? 

 

Thanks in advance. 

Mimi1456
Visitor
2 0 0

Hi All, 

If anyone reading this. I am lost. I cannot find this {{ product.url | within: collection }}

I am using the IMPULSE theme. 

Many thanks

korsakov
Shopify Partner
5 0 2

Found in product-thumbnail.liquid

in Parallax theme

BBStorm
Excursionist
24 0 11

I've changed {{ product.url }} to {{product.url | within: collection }} everywhere possible on my site and I can't get this to work properly. I need this to happen, take a look and let me know what I'm missing.

beautifulbystorm.com

BBStorm
Excursionist
24 0 11

Nvm, I got it now. 

I would also like for my "Recently Viewed' and 'You May Also Like' products are the last thing I have pointing to /product pages rather than /collections.

If anyone knows how to fix this please reach out. Thanks.

shettytarun
Tourist
4 0 2

@Tejas_Nadpara  Please can you let me know to fix the breadcrumbs issue as you have responded for the earlier message - where can I find the below code  in Minimal theme 

{{ product.url | within: collection }}

PaveSEO
Visitor
3 0 0

Hi @Tejas_Nadpara !

I'm using the Turbo theme. I have already solve the problem of editing the image links on the collections pages but not the caption underneath the image.

In the Snippets section, I went to  >> product-details.liquid 

The images all correctly point to the direct product page that has the canonical link.

But directly underneath the image, the captions themselves have the collections/collection-name/products/product-name links.

I don't know where to go to update those caption links.

Screen Shot 2021-11-03 at 11.45.32 PM.png

 

korsakov
Shopify Partner
5 0 2

Go through other snippets... There is some other file, which needs the same code replacement.

Other option is to do search among files

PaveSEO
Visitor
3 0 0

Thanks @korsakov! Found it in the product-thumbnail.liquid file under snippets.  

SarahMMoore1
Excursionist
18 0 7

Do you know how to do this for themes that use the JSON format? Most of our templates are JSON not "liquid"

interiorexpert
Tourist
10 0 4

@SarahMMoore1our theme uses JSON for "templates" as well. In the product.json for example you can find  "type": "main-product". This refers to the main-product.liquid that you can find in "sections"

 

korsakov
Shopify Partner
5 0 2

Thank you, @Tejas_Nadpara!

this helped a lot!

gelistirici
Visitor
1 0 0

Hi, I'm using Dawn theme. 

 

I removed a few within: collection codes but my problem was not completely solved.

The files you mentioned are not available in my theme. I wonder how I can remove these codes?

Fayyaz_Ahmed
Shopify Partner
176 34 65

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
Mike50
Excursionist
15 0 8

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 8

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
Visitor
2 0 0

Hi Mike, 

 

Did you have any success?

 

Cheers,

Jake

Lael_Uberuaga-R
Visitor
2 0 1

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 8

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
Visitor
2 0 1

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! 👍

Rich26
Visitor
1 0 1

From an SEO perspective, this is the opposite of what you actually want to do . The point is to push relevance to the collections pages so that they are your ranking landers for organic traffic. Instead, you are divorcing the products from their respective collections. The canonical should point TO the nested category page. Many ecomm CMS have this same issue because you might want to categorize the same product in multiple places. Generally you can manually set the canonical on the product page, but it seems like Shopify doesn't care that much about SEO optimization.

khoff
Shopify Partner
48 0 43

Shopify really doesn't seem to understand the whole SEO thing. We are being faced with every collection link being a 301 redirect to the canonical link of the products.  So now my site audits are showing that every single one of our products has a permanent redirect. 

 

Although using permanent redirects (a 301 or 308 redirect) is appropriate in many situations (for example, when you move a website to a new domain, redirect users from a deleted page to a new one, or handle duplicate content issues), we recommend that you keep them to a reasonable minimum. Every time you redirect one of your website's pages, it decreases your crawl budget, which may run out before search engines can crawl the page you want to be indexed. Moreover, too many permanent redirects can be confusing to users.

DavideCart
Tourist
3 0 0

Thank you for your help, but isn't it crazy that this happens? I went from 300 visits a day to 30 because of this problem....

Then with each theme update I have to reciprocate everything again... it's quite absurd this situation.

So you recommend that I change everything with product.url and I should solve the problem? As it seems to be just that...

 

Can I ask you if you can give me a check on the fly on my site https://cartonlineitalia.it ? I use screaming frog and I see that the first entry I get as an error is this one: "Canonical, transformed to canonical"
Thank you very much !

Adamzuo
Not applicable
3 0 0

For online store 2.0 theme, how we solve same problem? any one konw this?

interiorexpert
Tourist
10 0 4

I would be also interested if someone solved this with a store 2.0 theme.

 

We are using Focal theme, and there's no link with this structure in any liquid file: <a href="{{ product.url | within: collection }}“>. But Google indexed links like .com/collections/collection-name/products/product-name. For SEO reasons we only want to have this link structure: .com/products/product-name. I don't understand how this can happen...

 

Moreover Google indexed links like .com/collections/collection-name/tag. How are these links created? In our former theme the filter on the collection pages worked with tags. But now the filter is working completely different with meta fields like &filter.p.m.my_fields.metafield=value. There is no chance you can click a link like .com/collections/collection-name/tag on the collection page. How can that be indexed by Google?

 

Thanks for your help!

wonena-dev
Shopify Partner
21 0 8

I found it under Snippets: Card-product.liquid

and this is the URL that needs to be changed.

{{ card_product.url }}

Building a Sustainable Marketplace from Scratch
wonena-dev
Shopify Partner
21 0 8

I found it on the card-product.liquid under the {{ card_product.url }} name

Building a Sustainable Marketplace from Scratch