As you add more and more Sitemap classes to your sitemap, you may find the need to index them individually. Django provides a simple solution for indexing the Sitemap classes.
The django.contrib.sitemaps.views.sitemap view function accepts a section argument that is the string value of one of the keys in the sitemaps dictionary.
For example, the following code snippet defines a sitemap with two Sitemap classes, report and log:
sitemaps = { 'report': ReportSitemap, 'log': GenericSitemap(log_info_dict, priority=0.2, changefreq='daily'), }
The following URL pattern displays sitemaps for both the /sitemap-report.xml and /sitemap-log.xml URLs:
(r'^sitemap-(?P<section>.+).xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}),
Try It Yourself: Implement a Sitemap IndexIn this section, you will add a sitemap index that will index both the person and blog sitemaps that you created in the previous sections. Follow these steps to implement the sitemap index:
Listing 21.5. The URL Patterns Section for Sitemaps in the iFriends/urls.py File
|