在application.html.erb文件中添加的Canonical url标记无法在所有页面上工作
由于搜索引擎优化的原因,我在栏杆布局中将canonical
标记添加到了application.html.erb
,认为所有正在生成的网址都有自己的规范网址。但是在推向生产之后我检查了它。它似乎不像canonical
标签正常工作。在application.html.erb文件中添加的Canonical url标记无法在所有页面上工作
以下是canonical
标签在我application.html.erb
<link rel="canonical" href="<%= url_for(:only_path => false) %>" />
加入当我在网上规范检查程序进行确认,仅在主页/ root_url有一个适当的规范网址:
页网址:https://example.com/
规范网址:https://example.com/
,当涉及到其他的着陆页,它不能正常工作:
问题1:
页网址:https://example.com/search?category_id=metal-processing-and-machine-tool
规范的网址:https://example.com/search
。
问题2:
页网址:https://example.com/equipment_details/transformer-1250-kva-11-440-volts
规范的网址:NONE
这可能会导致在搜索引擎优化排名一个问题。请问有人能告诉我我该如何解决这个问题?
看看canonical-rails宝石。添加此宝石你的应用程序运行后rails g canonical_rails:install
添加<%= canonical_tag -%>
到application.html.erb
**
检查您参考以下链接:
**
https://github.com/jumph4x/canonical-rails
http://blog.planetargon.com/entries/easily-add-canonical-urls-to-your-rails-app