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

Luuk_Harleman
New Member
3 0 7

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
0 Likes
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
0 Likes
Jason
Shopify Expert
10275 144 1943

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 to help and share some insights. Not looking to be hired, and not looking for work.

Don't hand out staff invites or give admin password to forum members unless absolutely needed. In most cases the help you need can be handled without that.


★ http://freakdesign.com.au ★
0 Likes