How to Edit Your Shopify robots.txt File (And Hide Your Pages From Google)

As of 2026, you can now edit the robots.txt file of your Shopify store.

Shopify automatically creates a robots.txt file for you and sets you up with some useful default rules.

While this is handy, there are lots of reasons you might want to edit your robots.txt file, such as:

  1. Blocking certain bots from crawling your site altogether (such as AI bots like ChatGPT).
  2. Preventing bots from crawling certain sections or pages on your site.
  3. Explicitly allowing certain bots access to some or all of your site (e.g. you might want to explicitly allow Googlebot).
  4. Allowing bots to crawl your site, but slowing them down so they don’t overload your site (using a “Crawl-delay”).

Preventing a bot from crawling your page does not mean it won’t appear in search engines like Google. It still might—to hide pages altogether, you’ll also need to add a “noindex” tag to your page.

(don’t worry, I’ll explain what a noindex tag is and the easiest way to add one to your page).

Let me explain.

(but if you want to skip my explanation and just learn how to edit your robots.txt file, click here)

What is a robots.txt File?

A robots.txt file is a text file that tells search engines which pages to crawl or avoid, and how often to crawl them. This helps manage search engine traffic and prevents certain pages from being indexed. However, blocking a bot from crawling doesn’t guarantee the page won’t appear in search results. To hide pages completely, you also need to add a “noindex” tag.

Shopify Robots Txt

Search engines (like Google) use robots called “crawlers” to discover pages on your Shopify store.

Getting “crawled” by one of these crawlers is essential to getting your Shopify store ranking in Google and other search engines (if they can’t find your page, they can’t rank it).

A robots.txt file (also known as a “robots exclusion standard”) tells search engine crawlers which pages the crawler can or can’t request from your online store.

You might think the robots.txt file can hide a page from Google searches, but, surprisingly, it doesn’t work that way.

The robots.txt file is mainly used to avoid overloading your site with requests; it is not a tool for keeping a web page out of Google (or other search engines).

This is because if another website links to your website directly, a search engine crawler can still follow that link and find your page.

In this case it won’t read your robots.txt file, and can hence rank your page in Google.

To hide a web page from Google, you need to add a special code called a noindex tag to your page.

(Or password-protect your page, although that would mean users can’t visit the page while browsing your site).

A noindex tag is piece of code that tells crawlers not to crawl your page. It looks something like this:

<meta name="robots" content="noindex" />

If we add this to a page or product on your Shopify store, it will be hidden from search engines (like Google, Bing, and Yahoo).

If you want to hide a page from a search engine or AI bot, the best practice would be to do both: add the page or category to your robots.txt file, and add a noindex tag to the both.

Let’s jump into how to do this.

How To Edit Your Shopify robots.txt File

  1. From your Shopify admin, click Settings > Apps and sales channels
  2. From the Apps and sales channels page, click Online store
  3. Click Open sales channel
  4. Click Themes
  5. Click the … button, and then click Edit Code
  6. Click Add a new template, and then select robots
  7. Click Create template
  8. Make the changes that you want to make to the default template.
  9. Save changes to the robots.txt.liquid file in your published theme

Access the robots.txt.liquid Template

Log in to your Shopify admin and follow these steps:

  • Click Settings > Apps and sales channels.
  • Click Online store, then Open sales channel.
  • Click Themes.
  • Click the button, and then Edit Code.
  • Under Templates, click Add a new template and select robots.
  • Click Create template.

Add or Remove Directives Using Liquid Code

Use Liquid code to customize your robots.txt.liquid template. This preserves Shopify’s ability to update the file automatically in the future. You might want to add or remove particular directives to control how different search engines and bots interact with your site, improving your SEO and site performance.

To block all crawlers from accessing specific pages, like those with the URL parameter ?search=, use the following code:

{% for group in robots.default_groups %}
    {{- group.user_agent }}
    {%- for rule in group.rules -%}
        {{ rule }}
    {%- endfor -%}
    {%- if group.user_agent.value == '*' -%}
        {{ 'Disallow: /*?search=*' }}
    {%- endif -%}
    {%- if group.sitemap != blank -%}
        {{ group.sitemap }}
    {%- endif -%}
{% endfor %}

You might want to add this rule to prevent search engines from indexing pages with filtered content, which can dilute your SEO efforts by creating duplicate content.

Remove Default Rules

If you want to remove a default rule, such as blocking crawlers from accessing the /terms/ page, which might be important for users to find through search engines, use the following code:

{% for group in robots.default_groups %}
    {{- group.user_agent }}
    {%- for rule in group.rules -%}
        {%- unless rule.directive == 'Disallow' and rule.value == '/terms/' -%}
            {{ rule }}
        {%- endunless -%}
    {%- endfor -%}
    {%- if group.sitemap != blank -%}
        {{ group.sitemap }}
    {%- endif -%}
{% endfor %}

Removing this rule ensures that important legal pages like terms and conditions are accessible to users and indexed by search engines.

Add Custom Rules

To block a specific crawler, such as Antropic’s AI bot, add:

User-agent: anthropic-ai
Disallow: /

To allow a specific crawler, such as OpenAI’s ChatGPT crawler bots, add:

User-agent: GPTBot
Allow: /

Blocking specific crawlers can be useful to prevent certain bots from accessing your site, reducing server load and protecting sensitive content.

Include Extra Sitemap URLs

If you’ve got an additional sitemap that you want to include, add the following line to your robots.txt file

To add an extra sitemap URL, include:

Sitemap: [sitemap-url]

For example, you might replace [sitemap-url] with https://yourwebsite.com/sitemap2.xml.

Save and Test Changes

After making your changes, save the robots.txt.liquid file. Use Google’s robots.txt Tester to verify your changes. This ensures that your customizations work as expected and that there are no errors.

Delete robots.txt.liquid Customizations

If you need to revert to the default robots.txt file, you can delete the robots.txt.liquid template. Before doing this, save a copy of your customizations in case you need to reapply them later.

Handling Theme Updates

Keep in mind that uploading a theme from within the Themes section will not import the robots.txt.liquid file. To preserve your customizations, use ThemeKit or command line changes.

Consult Shopify Partner or Expert

If you are unsure about making these changes yourself, consider hiring a Shopify Partner. They can ensure that your customizations are implemented correctly and help you avoid potential issues.

Shopify Indexed Page Blocked by robots.txt

It’s important to understand that even if you block a page in your robots.txt file, search engines might still index it. This can happen if there are direct links to this page from either your website or another website.

Blocking a page using robots.txt prevents search engine crawlers from accessing it, but it doesn’t stop search engines from indexing the page if they find links to it from other sites. This can lead to unwanted pages showing up in search results.

To effectively prevent a page from being indexed, you should use a noindex tag along with your robots.txt directives. For detailed instructions on how to do this, see How to Hide Shopify Pages From Search Engines below.

How To Hide Shopify Pages From Search Engines

  1. Locate the theme.liquid file
  2. Identify the page handle of the page you want to hide
  3. Add in the code snippet

1. Locate The theme.liquid File

Here’s how to locate your theme.liquid file in Shopify. It is available for all online store themes.

  1. Log in to your site and go to the Shopify admin.
  2. Go to Online Store
  3. Go to Themes
  4. Choose your Shopify store theme
  5. Click Actions > Edit code
  6. Under the Layout folder, click on the theme.liquid layout file
Shopify Robots Txt Edit Code
Shopify Robots Txt Themeliquid

2. Identify The Page Handle Of The Page You Want To Hide

The page handle is an identifier in your page URL. For example, if the name of your product page is Amazing Tennis Balls, typically the page handle would be ‘amazing-tennis-balls’.

3. Add In The Code Snippet

Under the <head> tag in your theme.liquid layout file, you need to add a code snippet.

If you wanted to hide the Amazing Tennis Balls product pages for your Shopify store, paste in the following code:

{% if handle contains 'amazing-tennis-ball' %}
<meta name="robots" content="noindex">
{% endif %}

You can do this for any page handle you want. Simply replace ‘amazing-tennis-ball’ with the correct page handle. This code will hide a page with the URL containing the page handle from the search engines such as Google, Bing and Yahoo.

Click on the Save button to save your configuration.

How to Hide Multiple Pages From Search Engines

Unfortunately, there is no simple way of grouping all the pages you want to disallow search engines like Google and Bing from crawling. You’ll have to do the following.

  1. Make a list of all the pages you want to exclude from being indexed by Google, Yahoo, Bing and any other search engine.
  2. Convert the page names to page handles
  3. Edit the following code and insert it in the head section to disallow search engines from indexing the pages. Replace ‘page-handle-you-want-to-exclude’ and ‘another-page-handle-you-want-to-exclude” with the correct page handles.
{% if handle contains 'page-handle-you-want-to-exclude' %}
<meta name="robots" content="noindex">
{% elsif handle contains 'another-page-handle-you-want-to-exclude' %}
<meta name="robots" content="noindex">
{% else %}
<meta name="robots" content="index">
{% endif %}

4. Click the Save button to stop the pages from getting indexed in search results.

You might notice at this point that this process is highly manual. You have to add a new {% elsif handle contains ‘new-page-handle’ %} code in the <head> section any time you want to edit the Shopify robots.txt file.

This method is straightforward for small e-commerce sites but can become quite cumbersome for larger stores with many pages.

How to Hide the Search Template Page

If you want to ensure that your search template page doesn’t show up in Google or Bing’s search results, you can add a noindex tag to your theme.liquid file.

  1. Log in to your site and go to the Shopify admin.
  2. Go to Online Store
  3. Go to Themes
  4. Choose your Shopify store theme
  5. Click Actions > Edit code
  6. Under the Layout folder, click the theme.liquid layout file
  7. Include the following code in the <head> tag.
{% if template contains 'search' %}
<meta name="robots" content="noindex">
{% endif %}

8. Click the Save button. This will disallow search engines like Google from including your search template page in their search engine results pages (SERPs).

Conclusion

Managing Shopify SEO is easier now that you can customize your robots.txt file. By editing the robots.txt.liquid template, you can fine-tune which pages and bots interact with your site. This gives you more control over your site’s visibility and performance in search engines.

For best results, remember that using a noindex tag in combination with your robots.txt file is essential to fully exclude pages from search engines like Google. This dual approach ensures that your hidden pages remain unindexed while still allowing users to navigate your site freely.

With these tools, you can ensure your pages are indexed correctly, enhancing your site’s SEO and user experience. By taking control of your robots.txt file and using noindex tags where needed, you can effectively manage how search engines interact with your Shopify store.

If you’re looking for (free) tips to increase your Shopify conversion rate and rank higher on Google, you can follow me on Twitter 👉🏻 @bitofseo.

Please DM me if you have any questions about this Shopify article (or have some feedback to make it better 😄️).

About Jake Sacino

After working as an engineer and consultant for a bunch of big companies, Jake now works as a full-time SEO & software engineer.