How to correctly hide a webpage from Google search results?

Trying to hide one of the page in Google’s search results.

When you put the code:

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

Which way is the right way?

  1. Do you add a “full” handle to that code i.e: www.XYZ.com/pages/thank-you

  2. Only /pages/thank-you

  3. Or only: thank-you

@Kjankko-US May this help you. Click Here.

I have read that - and my code is from that page @DelightCart

Only wondering whats is the handle to put in that code. If my site’s URL is: www.XYZ.com/pages/thank-you

Do I add:

  1. a “full” handle to that code i.e: www.XYZ.com/pages/thank-you
{% if handle contains 'www.xyz.com/pages/thank-you' %}

{% endif %}
  1. Only /pages/thank-you
{% if handle contains '/pages/thank-you' %}

{% endif %}
  1. Or only: thank-you
{% if handle contains '/thank-you' %}

{% endif %}