django CMS page extension to handle sitemap customization
Support Python version:
- Python 3.8, 3.9, 3.10
Supported Django versions:
- Django 3.2, 4.1, 4.2
Supported django CMS versions:
- django CMS 4.0
Note
djangocms-page-sitemap 0.8 has been relicensed with BSD license.
Note
djangocms-page-sitemap 1.0 dropped compatibility with Python 2 and Django < 2.2
Note
djangocms-page-sitemap 2.1.0 moved to FidelityInternational org and renamed to djangocms-page-sitemap-fil dropped compatibility with Python < 3.8 and Django < 3.2
- Support for changefreq and priority customisation per-page
- Option to exclude a page from the Sitemap
- Values are cached
- django CMS toolbar integration
- Available on Divio Cloud
Install djangocms-page-sitemap:
pip install djangocms-page-sitemap
Add to
INSTALLED_APPS
withdjango.contrib.sitemaps
:INSTALLED_APPS = [ ... "django.contrib.sitemaps", "djangocms_page_sitemap", ]
Load it into the urlconf, eventually removing django CMS sitemap:
... urlpatterns = [ path("admin/", admin.site.urls), ... path("", include("djangocms_page_sitemap.sitemap_urls")), ... ]
Load
robots_index
templatetag and add it to the page in the head tag of the django CMS pages (or in a shared base template):{% load robots_index %} ... <head> <!-- somewhere in the head tag --> {% page_robots %} </head> ...
If you need to provide a custom sitemap configuration (for example to add more sitemap classes to it, you can append the sitemap url explicitly:
from django.contrib.sitemaps.views import sitemap from djangocms_page_sitemap.sitemap import ExtendedSitemap from myapp.sitemaps import MySiteSitemap urlpatterns = [ ... path("sitemap.xml", sitemap, { "sitemaps": { "cmspages": ExtendedSitemap, "myapp": MySiteSitemap, } ), ... ]
django-app-enabler is supported.
You can either
- Installation & configuration:
python -mapp_enabler install djangocms-page-meta
- Autoconfiguration:
python -mapp_enabler enable djangocms_page_meta
Fully using this package will require some changes that cannot be modified by django-app-enabler
:
- Remove any existing sitemap declaration from
urls.py
; - Load robots tags in the page like outlined above;
- Run migrations:
python manage.py migrate
Check documentation above for details.
After installing as above, you will be able to tune the sitemap setting for each page.
A new menu item Sitemap properties
will be available in the page toolbar.
For each page you will be able to set the following flags / values:
- Sitemap changefreq (default: the django CMS default)
- Sitemap priority (default: 0.5)
- Include page in sitemap (default:
True
) - Set
noindex
value to page robots meta tag - Set
noarchive
value to page robots meta tag - Provide any additional robots meta tag values
page_robots
meta tag accepts the following parameters:
page
: the page to render robots meta tag (default: current page). Can be any valid page lookupsite
: the current site id (default: current site).
- PAGE_SITEMAP_CHANGEFREQ_LIST: List of frequency changes
- PAGE_SITEMAP_DEFAULT_CHANGEFREQ: Default changefrequency (default: django CMS value -monthly-)
- PAGE_SITEMAP_CACHE_DURATION: Cache duration: same as django CMS menu cache)