Robots.txt files

Solved
Tom_Boie
New Member
3 0 0

Hi there,

I want to block Google from accessing the following pages and I'm aware we cannot edit the robots.txt file:

 

User-agent: *

Disallow: /account/login

Disallow: /account/register

 

Shopify has instructions to add to the theme.liquid page in the header to block particular pages. To action these two, would I enter the following in the header somewhere?

 

{% if handle contains '/account/login' %}
<meta name="robots" content="noindex">
{% endif %}

{% if handle contains '/account/register/' %}
<meta name="robots" content="noindex">
{% endif %}

Is it simply a copy/paste in a spare row in the header or will this overwrite text in the following rows?

Thanks in advance for any help!

0 Likes
Jason
Shopify Expert
10402 163 2045

Hey Tom,

The account pages will already be blocked by the robots file. You can also add the robots meta tag if you want to.

Now do keep in mind that some themes may already add the meta robots tag. You'll want to check that your theme isn't already doing that since two meta robots tags on the same page is a no-no. It doesn't look like your theme does, but still worth checking.

In theme.liquid you could place this code within the opening <head> and closing </head> tags:

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

^ that would add the robots tag if the template in use contains the word 'account'.

I jump on these forums to help and share some insights. Not looking to be hired, and not looking for work.

Don't hand out staff invites or give admin password to forum members unless absolutely needed. In most cases the help you need can be handled without that.


★ http://freakdesign.com.au ★
0 Likes
Tom_Boie
New Member
3 0 0

Hey Jason,

Thanks so much for your reply -

I've checked my theme.liquid and the only reference to robots is the following on lines 9-14 :

    <meta http-equiv="cleartype" content="on">
     {% if template contains "cart" %}
     <meta name="robots" content="noindex,nofollow">
     {% else %}
      <meta name="robots" content="index,follow">
      {% endif %}
   

Therefore, I think I can add the code you mentioned within the header:

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

Correct? If so, I can post it on line 15-17 where I have some blank space?

0 Likes
Trevor
Community Moderator
Community Moderator
2752 360 557

This is an accepted solution.

Hello!

As of today, June 21st, 2021, we have launched the ability to edit the robot.txt file to give merchants more control over the information that is crawled by search engines. You can learn more about how to edit your robot.txt file through our community post here

Due to the age of the topic, I will be locking this thread and marking it as resolved to help direct anyone that lands on this page. If you have any questions about the new feature, please do not hesitate to create a new post under our "Techincal QA" board.


Trevor | Community Moderator @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

0 Likes