Noindex collection page but not tagged pages

Garner
New Member
3 0 0

I am looking for the right code snippet for setting a collection page to noindex, but its tagged pages must remain indexable.

So for example:

.../collections/widget  is the collection to be set to noindex

but

.../collections/widget/blue and .../collections/widget/green etc are to remain indexable

Something like the following sets every page to noindex, I have tried different variations as well.

{% if template contains 'collection' and canonical_url contains '/collections/widget' %}
<meta name="robots" content="noindex,follow" />
{% endif %}

but the inclusion of something like and current_tags == false breaks and nothing is set to noindex

What is the correct code to exclude the tagged pages from being set to noindex?

 

 

 

0 Likes
ShanifAtApteo
Shopify Partner
35 2 6

 Hi @Garner, glad to help you with your question. I’m sure, my given answer will help to solve your problem as adding the given code below in the section

1: Go to Online Store > Actions > Edit Code > theme.liquid

And paste code between head tag like this

<head> 

  {% if collection.handle == "widget" %}

   <!-- No index code  -->

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

{% endif %}

</head>

Hopefully, that solves your problem. If not, please let me know if you're seeing any other issues.

 

Shanif Dhanani, CEO and data scientist at Apteo
- Was I able to help? Click Like to let me know!
- If I was able to answer your question, click Accept as Solution
- Want to increase your customer lifetime value with A.I.? Check out Apteo
0 Likes