Removing product tags from being indexed by Google

Removing product tags from being indexed by Google

Yvy616
Excursionist
35 0 48

Hi I created tags for the purpose of filtering in the store, and for my own organization but I know google indexes all these tagged pages. I don't want that. It leads to a potential to be dinged for duplicate content. I saw another post that had some code to add to the theme file, but I want to make sure that this code won't no-index my collection pages aswell. I just want to noindex the pages that get generated out of the product tags. If one product has 10 tags, google will index 10 pages that are the same! I saw someone had posted this code:

Is that all that's needed to not index tagged product pages, or will that also no index collections pages? (which I DO want indexed)

 

 

{% if template contains 'collection' and current_tags %}
<meta name="robots" content="noindex" />
<link rel="canonical" href="{{ shop.url }}{{ collection.url }}" />
{% else %}
<link rel="canonical" href="{{ canonical_url }}" />
{% endif %}

 

 

 

Replies 6 (6)

Twinwoods99
Tourist
6 0 2

This works! This should be in the library! 

Justin1994
Tourist
6 0 1

Hi,

 

I've been having the same issue. May I know if this code works for your website? If so, which template did you add this? I really appreciate your help and will look forward to your response! 

Vin-Twinwoods
Tourist
4 0 0

at the TOP above  <head>  portion in theme.liquid  

EchoLee
Visitor
1 0 0

Where should I add this code?

Vin-Twinwoods
Tourist
4 0 0

You can add it at the TOP above  <head>  portion in theme.liquid  

BRDE
Tourist
6 1 1

I had the same issue with blog taggs which lead to duplicate content. A small adjustment on the code above helps to sort them out: 

 

 

{% if template contains 'blog' and current_tags %}
<meta name="robots" content="noindex" />
<link rel="canonical" href="{{ shop.url }}{{ blog.url }}" />
{% else %}
<link rel="canonical" href="{{ canonical_url }}" />
{% endif %}