Remove /collections/.../products/... from product URLs – Capital theme

Topic summary

A Shopify store owner using the Capital theme wanted to remove /collections/.../products/... from product URLs to use only the canonical /products/product-name format, aiming to eliminate unnecessary redirects and SEO issues.

Initial Challenge:

  • Could not locate {{ product.url | within: collection }} in theme files
  • Struggled to find the correct files to modify in Capital theme’s structure

Guidance Provided:

  • Check files like snippets/product-grid-item.liquid, snippets/product-card.liquid, or sections/collection-template.liquid
  • Search for product.url or within: collection using Ctrl+F within code files (not file names)
  • Replace instances of {{ product.url | within: collection }} with {{ product.url }}
  • Set up URL redirects for already-indexed pages
  • Monitor Google Search Console after changes

Resolution:
The user successfully located the code in snippets/product-item.liquid and made three modifications:

  1. Product image link
  2. Product title link
  3. “View product” button link

All instances of | within: collection were removed, forcing all product links to use the canonical URL format.

Summarized with AI on October 28. AI used: claude-sonnet-4-5-20250929.

Hello,

I’m using the Capital theme on my Shopify store, and I’d like product links to use only the canonical URL format:

/products/product-name

Currently, many links include /collections/…/products/…, which creates unnecessary redirects and potential SEO issues.

I couldn’t find any {{ product.url | within: collection }} in the theme files, so I assume URLs are generated differently in Capital.

Could you let me know how to force product links to use only the canonical /products/… path, or where I can modify this in the theme?

Thanks in advance,

@Andre1689 , hey, thanks for posting here.
Can you please share some code file screenshots to identify the code, or share the theme files?

Hi @Andre1689

To ensure all product links in your Shopify store using the Capital theme use only the canonical URL format (__/products/product-name)-and not the longer /collections/…/products/… version-you’ll need to adjust your theme’s code so product links always point directly to the canonical product URL.

Here’s how to do it:

1. Backup Your ThemeBefore making any changes, duplicate your theme for safety.

Go to Online Store > Themes > Actions > Duplicate.

2. Find the Link Code in Your Theme FilesThe product links on collection pages are usually generated in one of the following files:

snippets/product-grid-item.liquid
snippets/product-card.liquid
sections/collection-template.liquid

Or similarly named files (the exact name may vary by theme).
Use the code editor’s search (Ctrl+F or Cmd+F*)* to look for product**.url** or within: collection in these files.

3. Update the Product Link CodeWhat to look for:

The code for product links often looks like this:


or similar.

What to change:
Replace it with:


This change will force all product links to use only the canonical /products/product-name URL, regardless of where they appear.

If you don’t see within: collection:
Some themes (like Capital) may already use {{ product.url }} or may generate links differently. In that case, ensure every instance of product links in your collection, featured product, or related product snippets uses {{ product.url }} and not a custom build that includes collection handles.

4. Test Your StoreGo to a collection page and click on a product.

The URL in the browser should now be /products/product-name without any /collections/…/ path.

5. Set Up Redirects (If Needed)If your store has already been indexed with the longer URLs, set up URL redirects:

Go to Online Store > Navigation > URL Redirects.
Redirect from /collections/collection-name/products/product-name to /products/product-name.

6. Monitor for IssuesCheck your site for broken links or unexpected behavior.

Monitor Google Search Console for crawl errors after making these changes.

Hello @PROSPRO

Here is a screenshot of me searching for product.url in my code, but no results came up. Am I searching in the right section?

@Andre1689 NO mate, here you just search file name, not code.

Hi @BiDeal-Discount ,

Sadly I’m not able to find any of those 3.

Here are 2 screnshots of what I actually have in sections and snippets

Is that because of the capital theme that I’m using?

Thanks for your help !

Oh I see thanks so i would have to do a CTRL+F in a code page and search for “product.url” or “within: collection”
I did look into most of them this afternoon but wasn’t able to find it.

@BiDeal-Discount encouraged me to look into those sections:
snippets/product-grid-item.liquid
snippets/product-card.liquid
sections/collection-template.liquid
I was able to find sections that resemble them like for exemple: collection.liquide in sections but no “product.url” or “within: collection”

@Andre1689 , can you please share the files for a fast solution?

I found it under snippet → “product-item”.

I had to make 3 changes:

  1. Product image link
    Modified line:
    {% assign image_link = item.url | within: collection %}
    Replaced with:
    {% assign image_link = item.url %}
  2. Product title link
    Modified line:
    {{ item.title }}
    Replaced with:
    {{ item.title }}
  3. “View product” button link
    Modified line:
    {{ “products.product.view_product” | t }}
    Replaced with:
    {{ “products.product.view_product” | t }}

Hello,

I found it!

I found it under snippets → “product-item”.

I had to make 3 changes:

  1. Product image link
    Modified line:
    {% assign image_link = item.url | within: collection %}
    Replaced with:
    {% assign image_link = item.url %}
  2. Product title link
    Modified line:
    {{ item.title }}
    Replaced with:
    {{ item.title }}
  3. “View product” button link
    Modified line:
    {{ “products.product.view_product” | t }}
    Replaced with:
    {{ “products.product.view_product” | t }}