zoukankan      html  css  js  c++  java
  • rails利用big_sitemap生成sitemap


    # Gemfile gem 'big_sitemap' # lib/tasks/sitemap.rake require 'big_sitemap' namespace :custom do desc "Generate sitemap" task :sitemap => :environment do include Rails.application.routes.url_helpers sitemap_options = { document_root: Rails.root.join('public'), url_options: { host: 'example.com' }, ping_google: true, ping_bing: true, gzip: true } if Rails.env.development? sitemap_options = { document_root: Rails.root.join('public'), url_options: { host: 'localhost', port: 3000 }, ping_google: false, ping_bing: false, gzip: false } end BigSitemap.generate(sitemap_options) do add root_path, change_frequency: 'daily', priority: 1.0 Shop.all.each do |shop| add shop_path(shop), change_frequency: 'daily', priority: 0.5 end end end end

     然后使用命令执行

    rake custom:sitemap
    

    在public文件夹下产生sitemap.xml 和 sitemap_index.xml 两个文件。

    可以把命令加在定时任务中,每天执行一次。

    具体详情:https://github.com/alexrabarts/big_sitemap

  • 相关阅读:
    UWA 技术分享连载 转载
    移动游戏加载性能和内存管理全解析 学习
    英语书籍阅读
    2017年6月
    Unity 官方文档学习
    YAML Class ID Reference
    Unity Blog 学习
    希腊字母
    2017年5月
    转载:书籍
  • 原文地址:https://www.cnblogs.com/wangyuyu/p/4093233.html
Copyright © 2011-2022 走看看