I have around 60000 URLs in my sitemap and the number keep growing by 5000 every day.
Google recommends to have only 50K urls in one sitemap, and if the number exceeds, then create another sitemap.
So, currently I have following code for sitemap generation in urls.py of the project
video_map = {
'queryset': Video.objects.all(),
'date_field': 'pub_date',
}
sitemaps = {
'static': StaticViewSitemap,
'blog': GenericSitemap(info_dict, priority=0.5,changefreq="daily"),
'videos': GenericSitemap(video_map, priority=0.2,changefreq="daily"),
}
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}),
)
What I want is to create second sitemap after the number of urls exceeds 50000, and third sitemap after the number of urls crosses 100K.
I read Django documentation but could not understand much out of it (how it will generate separate sitemap for each 50000 urls.) and this question here How to create index for django sitemaps for over 50.000 urls
Thanks
From the documentation:
The sitemap framework also has the ability to create a sitemap index that references individual sitemap files, one per each section defined in your sitemaps dictionary.
You can use the same sitemaps
object you have and pass it to django.contrib.sitemaps.views.index(), it will refer to the the individual (paginated) sitemaps:
urlpatterns = patterns('django.contrib.sitemaps.views',
(r'^sitemap\.xml$', 'index', {'sitemaps': sitemaps}),
(r'^sitemap-(?P<section>.+)\.xml$', 'sitemap', {'sitemaps': sitemaps}),
)