我有一个ROR应用程序,出售的项目,如椅子,桌子等。我正在使用gem sitemap_generator来生成网站地图。以下是我的网站地图的代码:
# Set the host name for URL creation
SitemapGenerator::Sitemap.default_host = "http://www.example.com"
SitemapGenerator::Sitemap.create do
add '/products', :priority => 0.7, :changefreq => 'daily'
end当我运行命令rake sitemap:refresh时,会在公共文件夹中创建一个sitemap.xml.gz。我的robots.txt如下:
# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
#
# To ban all spiders from the entire site uncomment the next two lines:
# User-agent: *
# Disallow: /
Sitemap: http://www.example.com/sitemap.xml.gz这是否意味着,我在www.example.com/products的所有产品都将可供谷歌索引?
谢谢!!
发布于 2016-02-03 21:18:34
首先,你最好使用url helper而不是显式路径。这样,如果路径由于routes.rb文件的修改而发生更改,您就不必担心站点地图出错了:
SitemapGenerator::Sitemap.create do
add products_url, priority: 0.7, changefreq: 'daily'
end接下来,上面添加的产品url只会将/products添加到您的网站地图中。您可能希望添加每个单独的产品,具体取决于它们的更改频率:
SitemapGenerator::Sitemap.create do
add products_path, priority: 0.7, changefreq: 'daily'
Product.all.each do |product|
add product_path(product), priority: 0.7, changefreq: 'daily'
end
endhttps://stackoverflow.com/questions/35177984
复制相似问题