How to change the product link on collection pages to canonical URL?

Google Search Console is reporting all product links that contain the collection slug as ‘Not Indexed - Alternate page with proper canonical tag’.

Here is an example of a product canonical URL

https://warehoos.com/products/6-mil-poly-cgsb-multiple-sizes

The link to this product from a collection page is

https://warehoos.com/collections/vapour-barrier/products/6-mil-poly-cgsb-multiple-sizes

Links like these are being increasingly flagged by Google Search Console with the above issue.

I want to modify the collection page code so that the link to the products are their canonical URLs without the collection slug.

Can someone please guide me which file to edit. I am using Empire theme.

Hey @jaffri

You can use this article to guide you on removing what’s called the collection-aware URLs.

https://www.ilanadavis.com/blogs/articles/remove-collection-from-shopify-urls

I don’t have the Empire theme so I can’t tell you which theme file but you can look through your files to find within:collection

Hi @jaffri ,

  1. Under Online Store, Go to Themes.

  2. Click on the three dots next to Customize button, click on Edit Code.

  3. Go to the section Snippets and click to expand the details.

Look for a file named "product-card-media-gallery." You can edit the code from there.

I believe depending on your Theme, the file could be named slightly differently.

Hope that helps.

Best of luck,

Clarice