Generating Sitemaps in Rails
I Am Trying to Generate a Sitemap for My Rails App. I Want to Generate Them on a Periodic Basis and Not on Every Hit. I Was Previously Using This to Generate...
I am trying to generate a sitemap for my Rails app. I want to generate them on a periodic basis and not on every hit. I was previously using this to generate sitemaps . This seems good for sitemaps under 50k urls. Now I want to create an index as well and divide my sitemaps based on page types that is all school pages will go into a school sitemap similarly for other pages like student, sports etc.
2 Answers
You can do that with that same gem you mentioned. Please read Generating multiple sitemaps
And if you want to set them to check only periodically you change the <changefreq></changefreq> to something like this: <changefreq> monthly </changefreq>
Using the sitemap_generator gem will be the easiest way to do it.
Simply write your generation login in sitemap.rb file and run rake sitemap:refresh to create your sitemap for the first time.
After doing that, run this command whenever you like by writing it in the crontab or using a gem like whenever which provides a dsl for writing periodic commands using cron.