将 rel=nofollow 添加到 Rails 中的 will_paginate 链接
有没有办法将“rel = nofollow”添加到rails中的will_paginate gem创建的链接中?
Is there any way to add "rel=nofollow" to the links created by the will_paginate gem in rails?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我发现覆盖 page_number 不起作用(并且也不会处理您的下一个和后退链接)。相反,我重写 rel_value:
将此类添加到 lib,并在您看来:
I find that overriding page_number does not work (and also wont take care of your next and back links). Instead, I override rel_value:
Add this class to lib, and in your view:
您需要创建自己的 LinkRenderer 并
在您的视图中使用它:
You need create your own LinkRenderer and use it
In your view :
在 will_paginate 3 和 Rails 3 中,我必须像这样重写 ActionView::LinkRenderer :
In will_paginate 3 and Rails 3 I had to override ActionView::LinkRenderer like this:
您还可以将以下元标记放入页面的
部分:
我发现这是一种更好的方法,因为您可以减少对 will_paginate gem 的依赖。
You can also place the following meta tag into the
<head>
section of your page:I found it to be a better approach as you reduce dependency on the will_paginate gem.