If your Shopify product URLs look like this:
/collections/collection-name/products/product-name
and you want clean, SEO-friendly URLs like this:
/products/product-name
then this complete tutorial will help you fix the issue step-by-step.
This guide is optimized for SEO and developers. You will learn:
Why Shopify creates collection-based product URLs
How to find the correct theme files in any Shopify theme
How to fix product URLs permanently
How to improve SEO and Google indexing
Best practices for Shopify product URLs
Why Shopify Product URLs Include Collections
Many Shopify themes use the following Liquid code:
{{ product.url | within: collection }}
or
{{ product.url | within: current_collection }}
This forces Shopify to generate URLs like:
/collections/women-bracelets/products/product-name
However, from an SEO perspective, the best practice is to use:
{{ product.url }}
which generates:
/products/product-name
Google prefers clean URLs because they avoid duplicate content and improve crawlability.
Universal Rule to Fix Shopify Product URLs
Whenever you see this code in your theme:
❌ Wrong:
product.url | within: collection
or
product.url | within: current_collection
✅ Replace it with:
product.url
This rule works in all Shopify themes.
How to Find the Correct File in Any Shopify Theme
Different Shopify themes store product link code in different files. Follow these steps to find it easily.
Step 1: Open Theme Code Editor
Go to:
Shopify Admin → Online Store → Themes → Edit Code
Step 2: Search in Theme Files
Use the search box and search for:
within:
or
product.url
Most Common Files Where Product URLs Exist
Snippets Folder
snippets/grid-item-product.liquid
snippets/product-card.liquid
snippets/card-product.liquid
snippets/product-grid-item.liquid
Sections Folder
sections/main-collection-product-grid.liquid
sections/featured-collection.liquid
sections/collection-template.liquid
Templates Folder (less common)
templates/collection.json
templates/product.json
Each theme may use different file names, but the logic is always the same.
Real Example: Before and After Fix
❌ Before (Collection URL)
<a href="{{ product.url | within: current_collection }}">
✅ After (SEO-Friendly URL)
<a href="{{ product.url }}">
Fix Form Action URLs (Important)
Some themes also use collection URLs in product forms.
❌ Before
action="{{ product.url | within: current_collection }}#has-options"
✅ After
action="{{ product.url }}#has-options"
Add Canonical Tag for Better SEO
To avoid duplicate URLs, add a canonical tag in your Shopify theme.
Open:
layout/theme.liquid
Inside the <head> section, add:
{% if template contains 'product' %}
<link rel="canonical" href="{{ shop.url }}{{ product.url }}">
{% endif %}
This tells Google to index only the /products/ URL.
Final Result After Fix
Your Shopify product URLs will look like this:
✅ SEO-Optimized URL
https://yourstore.com/products/product-name
❌ Avoided Duplicate URL
/collections/collection-name/products/product-name
SEO Benefits of Fixing Shopify Product URLs
Improved Google indexing
No duplicate content issues
Better crawl budget usage
Cleaner and shorter URLs
Higher chances of ranking in search results
Bonus Tips for Shopify SEO
Always link products using
/products/URLsAdd unique product descriptions
Submit sitemap in Google Search Console
Improve internal linking from collections and blogs
Avoid auto-generated duplicate pages
Conclusion
Every Shopify theme has different file names, but the solution is universal:
👉 Remove | within: collection from product URLs and use product.url.
Once you apply this fix, your Shopify store will have clean URLs, better SEO, and faster indexing in Google.
