SEO/Rails - 如何向每个“link_to”添加标题标签
我很惊讶 Rails 的创建者没有想到这一点,如果有人能提供帮助,那就太好了。
我们怎样才能
<%= link_to "My Title", :controller => "products" %>
自动改变这一点:
<%= link_to "My Title", :controller => "products", :title => "My Title" #basically a copy of the text %>
我认为这对SEO有很大帮助。
多谢!
亚历克斯
I'm surprised Rails creator didn't think about that, if someone can help, would be great.
How can we do to change this:
<%= link_to "My Title", :controller => "products" %>
to this automatically:
<%= link_to "My Title", :controller => "products", :title => "My Title" #basically a copy of the text %>
I think it could help SEO a lot.
Thanks a lot!
Alex
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是 Rails 3 方式:
进一步阅读:https://www.searchenginejournal.com/how-to-use-link-title-attribute- Correctly/
This is the rails 3 way:
Further reading: https://www.searchenginejournal.com/how-to-use-link-title-attribute-correctly/
你的问题是有效的,我不知道你为什么被否决,但是,rails 的创建者确实考虑过这一点。实际上,您可以以非常简单的方式完成此操作,而不是使用自定义方法使事情变得复杂:
您实际上可以添加任何您喜欢的参数,而不仅仅是标题。
希望这有帮助!
Your question is valid and I don't know why you are down-voted, but, the creator of rails DID actually think about this. Actually, you can do it in a very simple manner instead of complicating using a custom method:
You can in fact add any parameter you like, not just the title.
Hope this helps!
尝试类似的方法
还没有测试代码,也不记得确切的 link_to 规范,但我认为你明白了
Try something like that
Haven't tested the code and do not remember the exact link_to spec but I think you get the idea