首页 > 解决方案 > 如何noindex分页页面

问题描述

如何在 Shopify 中为类别的分页页面添加 noindex 标签?我找到了声称可以做到这一点的应用程序,但我相信它应该可以在没有应用程序的情况下完成。

谢谢

标签: shopifynoindex

解决方案


您需要知道要定位哪个模板,通常在 Shopify 中有分页的模板是:收藏、博客、搜索。

所以你应该能够在theme.liquid

{% if template.name == "collection" or
  template.name == "blog"
%}
  <meta name="robots" content="noindex, nofollow" />
{% endif %}

此 ^ 非常通用,因此如果您想更具体,可以检查页面对象(收藏、产品、页面、博客、文章等)handle

{% if collection.handle == "example" or
  page.handle == "example" or
  blog.handle == "example"
%}
  <meta name="robots" content="noindex, nofollow" />
{% endif %}

推荐阅读