Django sitemap generator

Our Library for A sitemap is an XML file on your website that tells search-engine crawlers or indexers how frequently your pages change and how “important” certain pages are in relation to other pages on your site. This information helps search engines index your site.

This Django sitemap framework library automates the creation of this XML file by letting you express this information in Python code. You have the ability to change and mention settings in your Django project's file. It is very convenient and easy to use library which detects the changes in your Django url configuration and reloads the new configuration making absolutely no manual interventions for your sitemap. Add a sitemap quickly to any Django website. It helps in creating Sitemaps in Django.

Sitemaps are simple XML files that are used to provide details for every URL on a website. They include location, date of last modification, change frequency and page priority. If you’ve got an international or multilingual site, you can also use your sitemap to note the relationship between language versions of a URL. This helps search engines to learn about the site’s structure and index your website. JSL Django Sitemap is a sitemap.xml creator for Django projects which iterates over all the url patterns in your main Django project and creates a ready to use sitemap. The sitemap.xml is useful in crawlers such as Google, Bing, Yahoo. We hope you like our app! Leave a star on our GitHub repository. Thanks!


You can install the JSL Django Sitemap from PyPI:

pip install jsl-django-sitemap
Example usage

1. Add necessary imports

from jsl_django_sitemap.views import sitemaps from django.contrib.sitemaps.views import sitemap from django.urls import path

2. In your main django project file add below in urlpatterns

sitemaps.get("static").protocol = 'https' # Set custom params as required by accessing properties sitemaps.get("static").changefreq = 'weekly' # Set frequency sitemaps.get("static").priority = 1 path('sitemap.xml', sitemap, {'sitemaps':sitemaps}, name='django.contrib.sitemaps.views.sitemap'),

3. In your main file add below


4. Add django built in sitemap in the INSTALLED_APPS

INSTALLED_APPS = [ # ... 'django.contrib.sitemaps', ]
  1. "ALL" means to include all the urls from all Django apps onboarded to a project. If you want only specific apps to be included in sitemap use below syntax in which we provide comma separated tuple containing your app names. "INCLUDE_APPS": ("myapp1","myapp2")
  2. FETCH_URL_FROM: should be one value from the list ["name", "pattern"] default for FETCH_URL_FROM is "pattern"
  3. By default, if pattern is provided then "^" prefix and "$" suffix in url pattern is removed.
  4. "IGNORE_URL_PATTERNS": ("./api/v1.", ) This flag is used to ignore certain urls matching the provided tuple of patterns which are regex compatible
View generated sitemap
Start the development server and visit