How to block index with "?" in collection page

How to block index with "?" in collection page

Leo-le
Shopify Partner
16 0 0

Although shopify's robots.txt blocks the index of collection pages with "?sort_by=" by default, there are still a lot of missing pages. Google search console reminds me that there are tens of thousands of collection pages with "?sort_by=" Blocked by robots, but indexed,

So how to remove index for collection pages with "?sort_by="

Replies 3 (3)

Leo-le
Shopify Partner
16 0 0

{% if template contains "search" or template contains "cart" or template contains "checkout" or template contains "account" %}
<meta name="robots" content="noindex" />
{% endif %}

 

This doesn't help me exclude collection pages with "?sort_by=" to index

Leo-le
Shopify Partner
16 0 0

I want to delete the index with "?sort_by=" in the collection page, although the robots.txt file is blocked, it is still indexed, so how to solve it through "noindex"

Leo-le
Shopify Partner
16 0 0

Liquid doesn't seem to be able to determine which pages have "?sort_by="