Sitemaps¶
- class cms.sitemaps.cms_sitemap.CMSSitemap¶
Bases:
SitemapSitemap for django CMS pages limited to public, non-redirecting, and anonymously accessible content on the current Site.
Targets the current Site and respects the project’s public languages. Pages are annotated with the latest
PageContent.changed_dateand exposes it vialastmod().Enable the sitemap framework and register the sitemap in your URL configuration.
# settings.py INSTALLED_APPS = [ # ... "django.contrib.sitemaps", ]
# urls.py from django.contrib.sitemaps import views as sitemap_views from cms.sitemaps.cms_sitemap import CMSSitemap sitemaps = { "pages": CMSSitemap, } urlpatterns = [ path("sitemap.xml", sitemap_views.sitemap, {"sitemaps": sitemaps}, name="sitemap"), ]
- items() QuerySet¶
Items are PageUrl instances for the current Site, filtered to only include those that are:
In a public language for the Site
Not redirects
Not login_required
The site is taken from the
SITE_IDsetting or identified from the current request using the Sites framework. (A custom site middelware is ignored by Django’s sitemap framework.)