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 https://github.com/kjvarga/sitemap_generator. 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.
Generating sitemaps in Rails
1.6k Views Asked by Adam Young At
2
There are 2 best solutions below
0
On
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.rbfile and runrake sitemap:refreshto 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.