We are a retailer selling products where each variant is a duplicate on our website (every color is an individual product). We managed to canonicalize these products, however if we want to remove them from sitemap by ticking the seo.hidden meta field, these products ALSO automaically are set to noindex nofollow. Which means don’t index this page in your search engine AND don’t follow links, which is bad for SEO. In order for the seach engine to follow and index these pages I tried to apply the following code to the liquid.header, however it did not work. Any ideas are much appreciated.
{% capture content_for_header_fixed %}
{{ content_for_header }}
{% endcapture %}
{% if product.metafields.seo.hidden == 1 or collection.metafields.seo.hidden == 1 %}
{{ content_for_header_fixed | remove: '<meta name="robots"
content="noindex,nofollow">' }}
{% else %}
{{ content_for_header }}
{% endif %}