Skip to content

Sitemap Generation outside of the rake task

Sunny Ripert edited this page Jul 1, 2020 · 3 revisions

If you need to generate a sitemap outside of the rake task (i.e. via a controller once something is published, etc) you can do it by using the below. the config_file should be the place your config file lives.

SitemapGenerator::Interpreter.run(config_file: Rails.root.join('config/sitemap.rb'))

and if you would like to ping

SitemapGenerator::Sitemap.ping_search_engines