How to Configure Shopify Robots.txt for SEO

How to Configure Shopify Robots.txt for SEO

Table of Contents

How to edit Robots.txt on Shopify

  1. Open your Shopify Dashboard
  2. Go to Online Store > Themes
  3. In the Live theme section, click Actions > Edit code
  4. Under the templates section, click “Add a new template”
  5. Change “Create a new template for” to Robots.txt
  6. Click “Create template”

Note: This won’t override your existing default robots.txt file. It will just help you create additional rules for your robots file.

This will create a Robots.txt.liquid file with the following code:

# we use Shopify as our ecommerce platform
{%- comment -%}
# Caution! Please read https://help.shopify.com/en/manual/promoting-marketing/seo/editing-robots-txt
{% endcomment %}
{% for group in robots.default_groups %}
{{- group.user_agent -}}

{% for rule in group.rules %}
{{- rule -}}
{% endfor %}

{%- if group.sitemap != blank -%}
{{ group.sitemap }}
{%- endif -%}
{% endfor %}

Add a new rule to an existing group

Here is the file modified to include a few default rules we tend to use for clients:

{% for group in robots.default_groups %}
{{- group.user_agent }}

{%- for rule in group.rules -%}
{{ rule }}
{%- endfor -%}

{%- if group.user_agent.value == ‘*’ -%}
{{ ‘Disallow: /collections/all*’ }}
{{ ‘Disallow: /collections/vendors*?*q=*’ }}
{{ ‘Disallow: /collections/types*?*q=*’ }}
{{ ‘Disallow: /collections/*?*constraint*’ }}
{{ ‘Disallow: /collections/*/*’ }}
{{ ‘Disallow: /collections/*?*filter*’ }}
{{ ‘Disallow: /collections/*?*pf_*’ }}
{{ ‘Disallow: /collections/*?*view*’ }}
{{ ‘Disallow: /collections/*?*grid_list*’ }}
{{ ‘Disallow: /collections/?page=*’ }}
{{ ‘Disallow: /blogs/*/tagged/*’ }}
{%- endif -%}

{%- if group.sitemap != blank -%}
{{ group.sitemap }}
{%- endif -%}
{% endfor %}

Let’s say we wanted to remove the rule blocking /policies/, here’s an example code to do that:

{% for group in robots.default_groups %}
{{- group.user_agent }}

{%- for rule in group.rules -%}
{%- unless rule.directive == ‘Disallow’ and rule.value == ‘/policies/’ -%}
{{ rule }}
{%- endunless -%}
{%- endfor -%}

{%- if group.sitemap != blank -%}
{{ group.sitemap }}
{%- endif -%}
{% endfor %}

The above information is gathered from this shopify discussion which is the most useful information we found about the Shopify robots. txt configuration for SEO.