Add noindex meta in Shopify Cart page

Today, our team received the Email from Google Search Console. It said that some of our Shopify pages has “Indexed, though blocked by robots.txt” warnings.

What does this mewan? “index my blocked pages”

Google support gives me the answer:

Indexed, though blocked by robots.txt: The page was indexed, despite being blocked by your website’s robots.txt file. Google always respects robots.txt, but this doesn’t necessarily prevent indexing if someone else links to your page. Google won’t request and crawl the page, but we can still index it, using the information from the page that links to your blocked page. Because of the robots.txt rule, any snippet shown in Google Search results for the page will probably be very limited.

And I can resolve this by two ways:

If you do want to block this page from Google Search, robots.txt is not the correct mechanism to avoid being indexed. To avoid being indexed, remove the robots.txt block and use ‘noindex’.

If you do not want to block this page, update your robots.txt file to unblock your page. You can use the robots.txt tester to determine which rule is blocking this page.

Since I don’t want my Cart page to be indexed by Google, so I have to add noindex meta to the pages with warnings.

There is a liquid file named social-meta-tags.liquid which contains metas for templates.

Yeah, that is what I am looking for!

The only thing I need to know is the page type of these warning pages. After a simple test, I found out that they are policy search cart.

The final step is adding the noindex meta.

1
2
3
4
5
6
7
8
9
{% if request.page_type == 'policy' %}
<meta name="robots" content="noindex">
{% endif %}
{% if request.page_type == 'search' %}
<meta name="robots" content="noindex">
{% endif %}
{% if request.page_type == 'cart' %}
<meta name="robots" content="noindex">
{% endif %}

原文作者: dgb8901,yinxing

原文链接: https://www.itwork.club/2022/01/26/Add-noindex-meta-in-Shopify-Cart-page/

版权声明: 转载请注明出处

为您推荐

体验小程序「简易记账」

关注公众号「特想学英语」

网页图片在某些 iPhone 机型下高度不正确