I need to disallow robots access to tagged blog post URLs

Solved
Dave_Mooney
Shopify Partner
8 0 1

The store is generating URLs for the tags on the store blog posts. For instance:

 

https://mydomain.com/blogs/news/tagged/dogs

https://mydomain.com/blogs/news/tagged/cats

https://mydomain.com/blogs/news/tagged/sheep

 

These URLs are being indexed by search engines, we do not want this.

 

Is it possible to disallow robots access to these pages?

 

I'm aware we cannot simply edit a robots.txt file on Shopify.

 

I'm aware I can use the following liquid code in template files: (or any other variation of an IF)

 

{% if handle contains 'page-handle-you-want-to-exclude' %}
    <meta name="robots" content="noindex">
{% endif %}

The problem is that we want the root of the blog, and all the blog posts indexed, just not these tagged pages, and as far as I can see, it's impossible to target those URL generated pages with a liquid IF statement.

 

I have played around with the blog object and tried to write something that can work with the URL to show my meta tag with the right conditions, but I cannot work out a way. I have tried fiddling with {{ blog.tags }}, {{ blog.url }}, {{ blog.title }}, {{ blog.handle }} etc etc

 

I think my question is....what does my IF statement condition within blog.liquid need to be to disallow indexing of tagged blog pages?

 

Any help massively appreciated!

0 Likes
Ceri-Waters
Shopify Partner
91 4 22

This is an accepted solution.

Hi Dave,

You should be able to use the 'current_tags' object.

e.g. {% if current_tags %}
             Block Robots
       {% endif %}

https://help.shopify.com/en/themes/liquid/objects/current-tags

Dave_Mooney
Shopify Partner
8 0 1

That's it! I didn't realise tags had their own section within the liquid object docs.

 

Thanks so much, now works exactly as I wanted :)

0 Likes
Ceri-Waters
Shopify Partner
91 4 22

No problem @Dave_Mooney are you able to mark it as 'Accept as solution' for others to see?

shahteas
New Member
1 0 0

Which liquid fie to use to block Robot access for current tag?


@Ceri-Waters wrote:

No problem @Dave_Mooney are you able to mark it as 'Accept as solution' for others to see?


 

0 Likes
Ceri-Waters
Shopify Partner
91 4 22

Hi @shahteas could you elaborate a bit more? The robots meta field is typically in the theme.liquid file or a 'header.liquid' part.

0 Likes
gviner99
Tourist
7 0 2

Hi there

I am having the exact same issue here and your solution is very helpful. I just have a question about the Block Robots command. Is that to be entered exactly as is - ie like this?

2021-03-22_170251.jpg

Because when i do so, all that seems to happen is that the words "Block Robots" are rendered onto the page. So i was wondering if when you said "Block Robots" you didn't intend those words to be written as they are, but were alluding to something else that I should know about.

 2021-03-22_170448.jpg

 

Thanks very much.

0 Likes
Trevor
Community Moderator
Community Moderator
2917 380 589

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. 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