Google indexing

Solved
New Member
7 2 0

INDEX A SPECIFIC COLLECTION PAGE (within a collection) 

 

Our store have 100's of collection pages that look similar to this:

 

/collections/jacket-winter-coat-mens

/collections/jacket-winter-parka-mens

/collections/jacket-fall-coat-mens

/collections/jacket-fall-coat-mens

 

If I only want google to index: jacket-winter-coat-mens

AND DO NOT want the rest of the collections to be indexed, would the following code work in between my <head></head> tag:

{% if template contains 'collections/' %}
<meta name="robots" content="noindex">
{% if template contains 'collections/jacket-winter-coat-mens' %}
<meta name="robots" content="allow">
{% endif %}

 

OR should I use the following code:

{% if url contains 'collections/' %}
<meta name="robots" content="noindex">
{% if url contains 'collections/jacket-winter-coat-mens' %}
<meta name="robots" content="allow">
{% endif %}

 

Am I missing or doing something wrong? should I use something else than url or template? or use other if, else statements? 

 

0 Likes

Success.

Shopify Partner
513 104 139

@DougAxen 

 

Yes, you are doing little wrong, try this following code:

 

If you want to allow only one collection to index then use following code:

{% if template contains 'collection' %}
  {% if collection.handle == 'jacket-winter-coat-mens'  %}
  	<meta name="robots" content="allow">
  {% else %}
  	<meta name="robots" content="noindex">
  {% endif %}
{% endif %}

If you want to allow multiple collections to index then use following code:

{% if template contains 'collection' %}
  {% if collection.handle == 'jacket-winter-coat-mens' or collection.handle == 'ABC' or collection.handle == 'XYZ' %}
  	<meta name="robots" content="allow">
  {% else %}
  	<meta name="robots" content="noindex">
  {% endif %}
{% endif %}

I hope it will help you.

 

Thank you,

Tejas

Shopify Expert | skype: tejas.nadpara
- Feel free to contact me on support@hexaecommerce.com regarding any help
- Like and Mark as an Accepted Solution if reply helpful
1 Like

Success.

New Member
7 2 0

@Tejas_Nadpara 

 

Awesome, when I see the code you provided, it seems pretty legit and clear.

 

Thank You!

 

I'll make sure to try it.

0 Likes

Success.

New Member
7 2 0

@Tejas_Nadpara 

 

I just had this thought cross my mind.

 

Instead of entering the 2nd code you provided, why not instead enter this:

{% if collection.handle == 'jacket-winter-coat-mens' or collection.handle == 'ABC' or collection.handle == 'XYZ' %}
  	<meta name="robots" content="allow">
  {% else %}
  	<meta name="robots" content="noindex">
  {% endif %}
{% endif %}

Basically, do I need to start with "if template" and then beneath "if collection-handle"?? Cant I just start with "if collection-handle"??

 

 

0 Likes

Success.

Shopify Partner
513 104 139

@DougAxen 

 

Yes, you must have to use my 2nd code, first it check either current page is collection or not. If page is collection then only it check for collection handle.

If you will not add first IF then noindex tag would be add in your all other pages like home, product, about, contact, faq, etc.. because if collection handle not match then it always add noindex tag in other pages too.

 

Thank you,

Tejas

Shopify Expert | skype: tejas.nadpara
- Feel free to contact me on support@hexaecommerce.com regarding any help
- Like and Mark as an Accepted Solution if reply helpful
1 Like