How to prevent specific pages from being indexed

Solved

How to prevent specific pages from being indexed

Boyi
Shopify Partner
13 0 1

Context:

  • We have set up privacy policy and terms of service as individual pages (/pages) instead of setting them up at the policies settings where the content will show under (/policies)
  • For pages setup under /policies, they are already blocked via robots.txt however, the same is not true for /pages
  • We have tried to add the following code in the <head> section of theme.liquid to prevent the page from being indexed:

        Boyi_0-1689725028623.png

 

Question:

  • Currently, when we inspect the pages, the "no-index" tag is not being reflected in the rendered HTML for both privacy policy and terms of service, what amendments are required?

 

 

Accepted Solution (1)

omarhussain
Shopify Partner
32 5 7

This is an accepted solution.

put this code in theme.liquid 

{% if template contains 'page' and canonical_url contains '/pages/privacy-policy'  or   template contains 'page' and canonical_url contains '/pages/terms-of-service'  %}

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

{% endif %}

View solution in original post

Replies 2 (2)

omarhussain
Shopify Partner
32 5 7

This is an accepted solution.

put this code in theme.liquid 

{% if template contains 'page' and canonical_url contains '/pages/privacy-policy'  or   template contains 'page' and canonical_url contains '/pages/terms-of-service'  %}

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

{% endif %}
Boyi
Shopify Partner
13 0 1

Thanks Omar