Skip to content

Hiding Pages · § 1.5.3

Adding Noindex via theme.liquid on Shopify

Published:

The Shopify-provided snippets, verbatim

Shopify's Hiding-a-page-from-search-engines doc provides two verbatim Liquid snippets for theme.liquid: a template-based condition that hides every page rendered by a given template type, and a handle-based condition that hides a specific resource by handle. Both inject the standard <meta name='robots' content='noindex'> tag conditionally. Both paste into the <head> of theme.liquid in the theme code editor.

The two snippets serve different scopes. Template conditions are right when you want to hide every page of a given type at once (every internal-search results page, every customer-account page, every gift-card page). Handle conditions are right when you want to hide a single resource with a known handle (one specific landing page, one specific blog post, one specific product if you can't use Unlisted).

Template-based conditions

Shopify's template-based snippet checks whether the current page's template name contains a target string. The most common use is to noindex every page rendered by the 'search' template — the internal-search results pages. Other template names worth knowing: 'cart', 'gift_card', 'customers/account', '404'. The default Shopify robots.txt already blocks /cart, /search, /policies/, and /admin from crawling, but adding a noindex meta tag on the rendered page is belt-and-suspenders.

liquid Template-based noindex (verbatim from Shopify Help)
 {% if template contains 'search' %}
  <meta name="robots" content="noindex">
{% endif %} 

The condition uses contains rather than == because Shopify's template name can include suffixes (e.g. product.special-edition). The contains match is intentional: it lets the rule apply to every template variant of a given type. Replace 'search' with the template prefix you want to noindex.

Handle-based conditions

The handle-based snippet checks whether the current page's handle contains a target string. Handles are URL-friendly identifiers: /pages/about-us has handle 'about-us', /products/linen-roman-shade has handle 'linen-roman-shade'. The condition is most useful for one-off pages with a stable, known handle — landing pages with their own URL but no search-indexing role, private launch destinations, internal-team microsites.

liquid Handle-based noindex (verbatim from Shopify Help)
 {% if handle contains 'page-handle-you-want-to-exclude' %}
  <meta name="robots" content="noindex">
{% endif %} 

The contains match also has a side effect: a handle condition for 'launch' will match every handle containing the substring — private-launch-2026, launch-event, product-launch-guide. If you want exact-match, use handle == 'specific-handle' instead. Multiple handles can be stacked with or: {% if handle == 'a' or handle == 'b' %}.

Where to paste in theme.liquid

Open Online Store > Themes > Actions > Edit code. In the file tree, open Layout > theme.liquid. The file's <head> section is at the top. Paste the snippet inside <head>, ideally above any other meta tags. The exact line doesn't matter as long as it's between <head> and </head> — but paste high in the head to ensure crawlers reading the first few hundred bytes encounter it early.

liquid theme.liquid head excerpt with both noindex conditions
 <head>
  <!-- ...existing head tags... -->

  {% if template contains 'search' %}
    <meta name="robots" content="noindex">
  {% endif %}

  {% if handle contains 'private-launch-2026' %}
    <meta name="robots" content="noindex">
  {% endif %}
</head> 

Verifying the noindex is live

Three verification methods, in order of reliability. (1) View source on the target page and search for 'noindex' — the meta tag should appear in the <head>. (2) Run curl https://yourstore.com/that-page | grep -i noindex from a terminal. (3) Use Google Search Console > URL Inspection on the target URL; the report should show 'Indexing allowed: No' with reason 'noindex' detected.

Shopify's SEO FAQ2 calls out the same debugging workflow: when an SEO element doesn't appear as expected, the troubleshooting trail goes through theme.liquid, main-product.liquid, and main-list-collections.liquid. If the noindex tag is missing despite the snippet being present, check that theme.liquid is still the active layout file (some themes use a different layout name for specific routes) and that the condition's string matches the actual template or handle.