Noindex, nofollow 与元标签 Ruby gem 不工作

Noindex, nofollow with meta-tags Ruby gem not working

我正在使用 meta-tags gem,并尝试将 noindex 和 nofollow 元标记添加到我的视图中。

在 HAML 视图文件中,我有:

- noindex_meta_tag
- content_for :head do
  - display_meta_tags noindex: true, nofollow: true

application_helper.rb中,我有:

def noindex_meta_tag
  set_meta_tags noindex: true
  set_meta_tags nofollow: true
end

我已经根据上面链接的文档尝试了很多变体,但仍然无法正常工作。

我是不是哪里做错了,还是我的应用程序的另一部分出了问题?

您可能需要使用 = 运算符输出结果,而不是 HAML 中的 -:

= display_meta_tags noindex: true, nofollow: true