How to edit Robots.txt on Shopify
- Open your Shopify Dashboard
- Go to Online Store > Themes
- In the Live theme section, click Actions > Edit code
- Under the templates section, click “Add a new template”
- Change “Create a new template for” to
Robots.txt
- 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.