How to Change The Product URL Structure in Shopify

I’ve been working with Shopify Plus a lot recently and, whilst I try and avoid SEO at all costs, I’ve been trying to fix a number of annoying limitations around things like the URL structure, applying large numbers of redirects, preventing certain URLs from being crawled etc.

Forcing the top-level product URL in Shopify

One of the things that I struggled with initially was updating the product URL format, which is natively set to include the collection path. So an example of a native Shopify product URL would be:

The canonical URL (and product URL if accessed directly) is natively set to the clean, top-level version of this product detail page (, however that’s not what most people want from a reporting perspective (depending on how you work on this side) and it also means that the value from internal links is relying on the canonical URL, rather than pointing directly to the top-level version.

So, after hacking around with a few things, I noticed that the product links in the collection page template is set in the “product-grid-item.liquid” file and this is set to “<a href=”{{ product.url | within: collection }}”>”, as per the below screenshot.

If you remove the “| within: collection” part of this reference, it calls the top-level version of the product URL, which is what we want. This will look like:

This will result in all product links from product list pages linking to the top-level (/products/product-url-key) version of the URL, matching the canonical URL.

Here’s the before and after from my test Shopify Plus store.

Native Shopify URL when accessing products via a collection page:

Top-level Shopify URL when accessing products via a collection page:

I hope this post is useful – if you have any questions or comments, please feel free to add them in the comments below.

Paul Rogers

Paul is an experienced eCommerce Consultant, specialising in all aspects of replatforming, requirements gathering and platform selection projects.

Paul has worked with most mainstream eCommerce platforms and has supported complex replatforming projects with retailers from all over the world. Paul also works on customer experience projects and solutions-focused work with various platforms - primarily Magento and Shopify Plus.

3 thoughts on “How to Change The Product URL Structure in Shopify

  1. Thanks a lot Paul! This article is very helpful! It’s hard to find
    any reasonable information on Shopify. However, I found your website,
    it’s the most valuable so far! Good job! Keep posting

  2. Hi Paul, great article. I am new and using Shopify Debut theme. I found the same code you mentioned in product-card-grid.liquid. I made my edit there. Worked GREAT. Thanks for a great useful article.

Leave a Reply

Your email address will not be published. Required fields are marked *