How can I effectively remove duplicate URLs in Shopify?

Hello Shopify Community,

So I’m trying to get rid of the duplicate URLs (/collections/collection-name/product/product-name) for my store, and I have read that the solution is to remove within: collection from product-grid-item.liquid. However, this isn’t working in my theme which is modified version of Impulse. Following is a list of other areas where I found within: collection in. Can you please advise removing which one should solve my issue? Thanks so much!

product-grid-item.liquid:

(tried this, not working)

  1. href=“{{ variant.url | within: collection }}”

product-template.liquid

  1. {%- assign review_link = product.url | within: collection | append: ‘#Reviews-’ | append: product.id -%}

  2. data-product-handle=“{{ product.handle }}”
    data-product-url=“{{ product.url | within: collection }}”
    data-aspect-ratio=“{{ 100 | divided_by: product.featured_media.aspect_ratio }}”

Remove every occurrence.

Changes per below:


product-grid-item.liquid:


href="{{ variant.url }}"

+{{color_show_limit | minus: 6}}

product-template.liquid:

{%- assign review_link = product.url | append: '#Reviews-' | append: product.id -%}
data-product-handle="{{ product.handle }}"
data-product-url="{{ product.url }}"
data-aspect-ratio="{{ 100 | divided_by: product.featured_media.aspect_ratio }}"

Hi @P1Commerce
Removed from all instances but unfortunately still not working.

These changes will change the links that use the collections path in the links to products. If you have places where the urls are still using the collections path, then you have additional templates needing editing or you’re working in the incorrect theme.

Note that this change doesn’t prevent the urls with collections paths from working, it only changes the links to those urls.