How to block crawling of 1 specific page in robots.txt

Hi All,

I want to block a specific page URL from being crawled. I have tried using the theme.liquid and added this code but it didnt work:

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

I tried adding this to the robots.txt file

disallow: /a/XXXX 

under user-agent, adsbot-google etc.
But this didnt work either.

Finally I tried this code at the bottom of robots txt but it also didn’t work. Can someone help?

{%- if group.user_agent.value == ‘*’ -%}

{{ ‘Disallow: [URLPath]‘ }}

{%- endif -%}

I’m testing crawlability via this link and it keeps coming up saying it’s crawled: https://search.google.com/test/rich-results/

Could you share that page link?

I would prefer not to because of scammers/copiers etc.

It’s just a URL on the site. like domain.com/page/page

Can anyone help please?

@Dan-From-Ryviu can you please advise? you shouldn’t need the URL. Lets just give it a name https:// domain.com/page

Please add domain.com/page/page.json to get the ID of the page

After that, please add this code to theme.liquid file

{% if page.id == page ID goes here %}

{% endif %}

@Dan-From-Ryviu appreciate the response, it doesn’t seem to work, I just get “error occured on client”. The page directory is domain.com/a/faq which renders the page. So if I add faq/page.json I get the error. if I do faq.json it is a 404?

You can easily get the page id from admin.

Open Online store then pages

Open the page in admin & check the URL You can see something like

https://admin.shopify.com/store/[your-store-name]/pages/1986285850919

that number is your page.id