FROM CACHE - en_header

HELP! How to hide a string of URLs from search pages

Luuk_Harleman
New Member
3 0 8

I have a string of urls that are being indexed but I dont want them to:

For example
https://www.crispgolf.com/collections/headwear/products/crsp-hdw-101?variant=24587625863

As we cant edit the robots.txt file (very strange) im wondering the following: this guide tells me to put this code into the header of my template to exlude urls:

{% if handle contains 'page-handle-you-want-to-exclude' %}
<meta name="robots" content="noindex">
{% endif %}

Now I want to exclude all url strings that contain "?variant=" so I was thinking to put the code like this

{% if handle contains '/?variant=' %} <meta name="robots" content="noindex"> {% endif %}

Though that doesnt seem to work so how would I go about this?

Thanks

Crisp Golf
Replies 3 (3)
Steve76
Tourist
21 0 3

Luuk - This code did work, those pages now have noindex added (see screenshot). But, why do you want to do this? All of your product pages use this string and you are going to drop all of your products from Google. 

PromoPrep.com : Intuitive Promotion Planning Software
Jason
Shopify Expert
10961 196 2213

Your theme is taking a single product, and showing all the variants on the collection page. By doing that however, the theme is also linking to that specific variant - which is where that url with the variant id comes from.

You could just link directly to the product, but the drawback with that is that the default variant (the first) will be shown. So if someone clicked on one colour item they might not see that by default.

You could of course not use variants and just make these different products but that could pose a problem with dudplicate content - unless you're writing something unique for each.

 

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★
Trevor
Community Moderator
Community Moderator
3243 439 793

Hello!

As of today, June 21st, 2021, we have launched the ability to edit the robot.txt file to give merchants more control over the information that is crawled by search engines. You can learn more about how to edit your robot.txt file through our community post here

Due to the age of the topic, I will be locking this thread. If you have any questions about the new feature, please do not hesitate to create a new post under our "Techincal QA" board.

Trevor | Community Moderator @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog