Google indexing

Solved
Highlighted
Tourist
11 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
Highlighted
Shopify Partner
900 193 347

This is an accepted solution.

@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
- Like and Mark as an Accepted Solution if reply helpful
- Feel free to contact me on support@hexaecommerce.com regarding any help
1 Like
Highlighted
Tourist
11 2 0

This is an accepted solution.

@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
Highlighted
Tourist
11 2 0

This is an accepted solution.

@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
Highlighted
Shopify Partner
900 193 347

This is an accepted solution.

@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
- Like and Mark as an Accepted Solution if reply helpful
- Feel free to contact me on support@hexaecommerce.com regarding any help
1 Like
Highlighted
Shopify Partner
85 6 38

Where do I have to maintain this in a section template like DEBUT? Is this also valid for "pages"?

0 Likes
Highlighted
Shopify Partner
900 193 347

@Michael_Singer 

 

Check your theme.liquid file and add this code between the <head></head> tag. For page template you can use following code:

{% if template contains 'page' %}
  {% if page.handle == about-us' or page.handle == 'contact-us' %}
  	<meta name="robots" content="allow">
  {% else %}
  	<meta name="robots" content="noindex">
  {% endif %}
{% endif %}

You can add multiple page handle as per your requirement.

 

Thank you,

Tejas

 

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