Skip to content
Log in

Implement 'noindex' tags on specific pages using Liquid

On this page

Use this process to keep specific pages out of search engine results by adding a Liquid template to the content block in your store’s HTML Head Content Block field. The template inserts a noindex meta tag when the visitor is on one of the paths you list.

Before you start

You need a store where you can edit the content block in its HTML Head Content Block field. See Adding custom JavaScript, CSS and head content.

Add the noindex template

  1. Open the Store record and find the Global Content section.

    Global Content section on the Store record showing the HTML Head Content Block field

  2. Open the content block in the HTML Head Content Block field, or create a new one and set it there.
  3. Paste this Liquid into the block’s Content field.

```liquid

{% assign noindex_pages = "/omnico,/omnico/conservation,/omnico/products/water-conservation" | split: "," %}
{% assign path_to_check = current_request.path | strip_newlines | strip %}
{% assign is_noindex = false %}
{% for page in noindex_pages %}
  {% if page == path_to_check %}
    {% assign is_noindex = true %}
  {% endif %}
{% endfor %}
{% if is_noindex %}
  <meta name="robots" content="noindex">
{% endif %}
```
  1. Replace the values in noindex_pages with the paths you want to exclude, as a comma-separated list. Each path is compared to current_request.path exactly, so write it with a leading slash and no domain, for example /summer-sale. A path without the leading slash never matches.

    :::note On a store mounted at a path, current_request.path includes that store path, so /summer-sale on a store mounted at /au is /au/summer-sale. Either include the store path in your list, or swap current_request.path for current_request.local_path, which strips it. :::

  2. Select Save.

Verify the tag is present

  1. Open one of the excluded pages on your live storefront and refresh it.
  2. View the page source and search it for noindex.

    Browser page source showing the noindex meta tag inserted by the Liquid template

The <meta name="robots" content="noindex"> tag now appears in the <head> of every page you listed, and on no others. Search engines drop those pages from their index at their next crawl, which can take days or weeks.

Was this article helpful?

Was this article helpful?