Shopify says to utilize the following sample to noindex a specific page in shopify.

To exclude a specific page, paste the following code in the section:

{% if handle contains 'page-handle-you-want-to-exclude' %}
<meta name="robots" content="noindex">
{% endif %}

However, the "contains" is an issue I think. For example, I specifically want to noindex the default created /collections and /collections/all pages. But, if I noindex those with a contains option, any page handle that "contains" that would be no-index. That is an issue because then all collections would be noindex by doing that to '/collections' and if I just do it to 'collections/all', that would also noindex a collection that utilizes the url /collections/all-supplements.

Instead of contains, can I do =? Or what should I place to force an exact url to be noindex?

After determining what the proper operator is... what does Shopify consider to be the handle?

Would I do 'collections' or '/collections' or '/collections/'? For the other, would I do 'collections/all' or '/collections/all' or '/collections/all/'?

1

There are 1 answers

0
Alice Girard On

For the "/collections" page, you may use the request object like this:

{% if request.page_type == 'list-collections' %}
    <meta name="robots" content="noindex">
{% endif %}

For the collection page automatically created, the handle will always be "all" (/collections/all), and you may use a strict condition:

{% if handle == 'all' %}
    <meta name="robots" content="noindex">
{% endif %}