1

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

4

1 回答 1

4

文档中:

站点地图框架还能够创建引用单个站点地图文件的站点地图索引,每个站点地图字典中定义的每个部分都有一个。

您可以使用sitemaps您拥有的相同对象并将其传递给django.contrib.sitemaps.views.index(),它将引用单个(分页)站点地图:

urlpatterns = patterns('django.contrib.sitemaps.views',
    (r'^sitemap\.xml$', 'index', {'sitemaps': sitemaps}),
    (r'^sitemap-(?P<section>.+)\.xml$', 'sitemap', {'sitemaps': sitemaps}),
)
于 2014-12-21T09:12:24.360 回答