How can I prevent Google from indexing specific tag-filtered pages on my website?

How can I prevent Google from indexing specific tag-filtered pages on my website?

nicolaspat
Visitor
2 0 1

Hello, 

 

I just noticed that some URL pages of my website are indexed with the tag of filters, as well as our regular pages. How can I explain to google, to do not index those pages with filters/tags?

 

For example, I have a meta title on google: E-Shop - My Website - Tagged "category__outerwear, size__ ...

and a URL: https://mywebsite.fr/collections/all/size__xxl%20category__outerwear

 

Can you help?

 

Best,

 

Nicolas.

Replies 7 (7)

freddy123
New Member
6 0 0

Yeah I've just come across this and am wondering 1) whether it is a problem? 2) how I can fix it if so. I'm going to keep searching by am not an expert - let me know if you have come across anything! 🙂

Twinwoods99
Tourist
6 0 2

Same here - is there a way to locate the filter and set rules? So far I can use metafield with noindex set to false or true, but I don't want to filter pages to be indexed.  

frankymartin
Shopify Partner
32 0 22

Hi, I have tried with the next code in theme.liquid but is not working;

 

{% if template contains "collection" and collection.handle == "?filter" %}
<meta name="robots" content="noindex, follow">
{% endif %}

 

{% if handle contains '?filter=' %}
<meta name="robots" content="noindex, nofollow">
{% endif %}

 

Any help?

 

I also blocked it in robots.txt with;

{{ 'Disallow: /collections/*?*filter*' }}

Vin-Twinwoods
Tourist
4 0 0

Try 

{% if template contains "collection" and collection.handle contains "?filter" %}

frankymartin
Shopify Partner
32 0 22

Thanks @Vin-Twinwoods but it does not work. Any other idea?

Vin-Twinwoods
Tourist
4 0 0

Try this set in your theme header - you can modify to fit your needs. 

- note I also set metafield to collection or page so it is a quick solution for you too. 

 

{% if handle contains 'types' or template contains 'search' or template contains 'cart' %}<meta name="robots" content="noindex, nofollow" /><!-- ID: search-type-cart -->
{% elsif product_url contains 'view=list' %}<meta name="robots" content="noindex, nofollow" /><!-- ID: view-list -->
{% elsif request.page_type == 'collection' or request.page_type == 'page' %}
{% if template contains 'collection' and current_tags %}<meta name="robots" content="noindex, nofollow" /><!-- ID: tags-filter -->
{% elsif template contains 'collection' and product_url contains 'page=' %}<meta name="robots" content="noindex, nofollow" /><!-- ID: collection-pagination -->
{% elsif collection.metafields.robots.noindex == 'false' or page.metafields.robots.noindex == 'false' %}<!-- indexed collection / page by metafield" -->
{% else %}<meta name="robots" content="noindex, nofollow" ><!-- ID: meta-field-default-noindex -->
{% endif %}
{% elsif product_url contains 'variant=' or product_url contains 'currency=' %}<meta name="robots" content="noindex, nofollow" /> <!-- ID: variants & currency -->
{% else %}
{% endif %}


 

Rene89
New Member
8 0 0

I have the same problem and tried everything. The problem is that the URL for filtered collection pages contains a question mark (?) which is not in Shopify's URL handle so you can't target it with this code.