Canonical URL issue Cannot find {{ product.url | within: collection }} anywhere

I use ahrefs.com to audit my website. I have 500+ orphaned webpages “Canonical URL has no incoming internal links”

All of the webpages are www.sitename.com/products/productname

My understanding is this is the canonical page and my site does not refer to this page. All our products are in categories and display the noncanonical page name i.e. https://sitename.com/collections/collectionname/products/productname

I have found a few people having my same issue and the say just go into _____.liquid file and change {{ product.url | within: collection }} to simply say {{ product.url }}

I have looked everywhere for this. I have looked in every .liquid file and I cannot find {{ product.url | within: collection }} anywhere. Can anyone help me out?

1 Like

Hi @SageFixer ,

What theme are you using? please send me the theme name, I will check it for you.

About the code, the instructions you have read are correct, just change:

{{ product.url | within: collection }}

=>

{{ product.url }}

Wow, thank you so much, this is the theme I am using Production Remove MapBox 2.29.20

Hi @SageFixer ,

I checked the attached link and couldn’t find any information about the theme.

You can go to Actions > Edit code, find ‘product’ and search for the code in the files of the snippets folder. Example for dawn theme is:

Hope it helps!

1 Like

Thank you so much! I found it under product-details.liquid

Very happy to have sorted this out.

Thanks again for your help!

Hi @SageFixer ,

If it helped you solve your issue, please mark it as a solution. Thank you and good luck.

Hi @LitExtension

I am using an Electro 6.0 theme and the same as well I am using ahref tool and it shows canonical error (no incoming internal links) and the orphan page (no incoming internal links) and most of them say those

{{ product.url | within: collection }}

=>

{{ product.url }}

Where do I find it in the electro 6.0 theme ? could you please check it for me and give a solution?

1 Like

I have been trying to solve this for two days now and there is no clear and helpful answer on shopify. I really don’t understand WHY Shopify makes it sooo difficult for store owner - or even developers - to solve common and simple problems. So frustrating!

1 Like

Any ideas about where to do this within the Expanse theme? I can’t find it.

Edit: found it. It’s in product-grid-item.liquid

Hello,
I found the code {{ product.url | within: collection }} in my product-grid-item.liquid file. However it is found 3 separate times, grid product link, add to cart and sold out. Do I change for each occurance?