sitemap_generator 生成 Sitemap
- 安装
编辑Gemfile
1
gem 'sitemap_generator'bundle install安装完成之后, 执行
1
rake sitemap:install会在config目录下生成sitemap.rb
*配置
将SitemapGenerator::Sitemap.default_host = “http://www.example.com”里的url改为自己的网站url
通过下列方法,可以将所有文章生成出去
123
Post.all.each do |a| sitemap.add post_path(a), :lastmod => a.updated_at end*生成
在crontab定时器里运行下列命令
1
rake sitemap:refresh就会生成sitemap并且向搜索引擎进行提交