All things Shopify and commerce
Hi there,
We would like to get rid of the parameters/string added to the product URLs when they are clicked from the "you may also like" (recommended products) section. Is there a way to alter/customize the recommended-products.liquid file code so that it loads only the product URL without the parameters that include section and product ID etc such as this:
domain/product/product-name?pr_prod_strat=collection_fallback&pr_rec_pid=5414698614950&pr_ref_pid=5428804255910&pr_seq=uniform
We want to remove those parameters as Google is starting to index this ugly/messy URLs which are obviously same as the original product URLs (content wise). Anybody has a solution to this, knows how to load/call for the original product URL without the parameters? (PS: I'm not a developer, I just need this info to guide the developers). At least to "hide" it from the end users?
(I contacted chat support for this but it wasn't helpful as they simply told me that it's because of the theme and not related to Shopify. However, I don't think this is true because I checked other random Shopify stores with different themes and I do believe that this is about Shopify's recommended products section code/the way it works. Even the code shown on Shopify dev tutorial pages indeed includes such parameters like section and product ID so I don't understand why the support don't accept that this is what their code is calling and blame it on the theme...) I mean like below code is from Shopify documentation where you can clearly see that it's calling for i.e. product ID (even I can see that as a non-tech person):
{% assign heading = 'You may also like' %} {% assign limit = 4 %} <div class="page-width product-recommendations" data-base-url="{{ routes.product_recommendations_url }}" data-product-id="{{ product.id }}" data-limit="{{ limit }}" data-section-id="{{ section.id }}" data-section-type="product-recommendations"> {% if recommendations.performed %} {% if recommendations.products_count > 0 %} <div class="section-header text-center"> <h2>{{ heading }}</h2> </div>
source: https://shopify.dev/tutorials/customize-theme-recommend-products
Thanks!
Hi, did you find out how to remove this URL parameters?
Any Luck on this?
I have already found this piece of code coming from the JS on 4th step on this link - https://shopify.dev/tutorials/customize-theme-recommend-products
But removing that breaks the functionality..
First of all, I doubt there is harm in having these URLS -- each product page has (should have) canonical url which points to the short form of the product url, so this should not produce any extra indexed pages.
Indeed, having these parameters in the product URL helps Shopify engine to see which of the recommended products are more relevant, helps refine its recommendations based on actual customers selections.
Anyway, the code in step 3 of the tutorial forms URL to fetch the product recommendations section and then uses it to fetch the actual HTML and "paste" it into product page. Changing it would not change the product URLs.
The actual rendering of recommended products is performed by liquid code in step 1 -- it basically calls your product-card-grid snippet, same snippet used to output product cards on collection pages:
{% for product in recommendations.products %}
<li class="grid__item small--one-half medium-up--one-quarter">
{% include 'product-card-grid', max_height: 250 %}
</li>
{% endfor %}
So, if you still really want to remove those URL parameters, I'd go into product-card-grid snippet code, find something similar to
href="{{ product.url }}"
and replace it with
href="{{ product.url | split: "?" | first }}"
Your theme may use different snippet name, but the idea is the same.
Thanks Tim! Used this solution for Dawn theme across the site.
To remove parameters in Search as well, had to amend all of the href instances (item.url and card_product.url) in the following files:
main-search.liquid, predictive-search.liquid, card-product.liquid.
I just did the same as you mentioned above. But I have concerns that parameters have a purpose and without params will start showing wrong recommended products. What do you think about it? @tim
Hi Tim,
I'm hoping you can help me with a related issue. I'd like to block selected URLs from our Shopify because the recommended product section at the bottom of each page is displaying / creating a longer URL than it should. At the end of each URL, there's an extra bit like this: "?pr_prod_strat=use_description&". This has caused problems in Google Search Console and I want to block these to stop these pages from being crawled. If you could assist me that would be greatly appreciated!
Hi , the solution is:
- Go to card.product.liquid file (could be another file)
- Search for "card_product.url"
- Replace all by "card_product.url | split: "?" | first"
Example:
<div class="card-wrapper">
<a href="{{ card_product.url | default: '#' }}" class="full-unstyled-link">
<span class="visually-hidden">{{ card_product.title | escape }}</span>
</a>
By :
<div class="card-wrapper">
<a href="{{ card_product.url | default: '#' | split: "?" | first }}" class="full-unstyled-link">
<span class="visually-hidden">{{ card_product.title | escape }}</span>
</a>
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025