Have your say in Community Polls: What was/is your greatest motivation to start your own business?

Add noindex tag to collection paginated pages

Add noindex tag to collection paginated pages

anksnz007
Shopify Partner
1 0 1

Hi,

 

I have searched a lot for a solution to add a noindex by editing theme.liquid file to add "noindex" to paginated pages of collections, but don't think there is a solution and if there is then those pages are archieved.

 

Example: https://www.example.com/collections/example-category?page=4

 

I'm specifically looking to noindex all collection that contains '?page=" but unable to.

 

This is what I'm currently at, but not working

{% if template contains 'collection' and collection.handle contains '?page=' %}

<meta name="robots" content="noindex, follow" />

{% endif %}

 

 

If I try the below, it adds noindex to all the collections as well, which I do not want.

 

{% if template contains 'collection' and current_tags %}

<meta name="robots" content="noindex, follow" />

{% endif %}

or 

{% if template contains 'collection' and current.filters != blank %}

<meta name="robots" content="noindex, follow" />

{% endif %}

 

Please only reply if you can provide a solution to the above. Thanking heaps in advance.

 

P.S: I'm not looking for a canonical solution, that thing is already working. Thanksssss

Replies 3 (3)

harsha2312
Shopify Partner
4 0 1

Hi @anksnz007 

 

I have been trying to do the same but could not achieve the result and then I used the following code which got me the result I wanted. Please try it.

 

{% if canonical_url contains '?page=' %}
<meta name="robots" content="noindex" />
{% endif %}

 

Let me know if this works. It worked for me.

 

Best Regards,

Harsha

Web Developer

marklittel
Visitor
1 0 1

Thanks, it worked for me too....

larsonreever
Tourist
5 0 1

I have also added it to my site after visiting this thread, Helpful info . Thanks