JSoftware Labs Logo
JSoftware Labs

Django Sitemap Generator

Automate sitemap creation for Django projects with our JSL Django Sitemap library. Easy to use, configurable, and SEO-friendly sitemap generation.

What is a Sitemap?

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.

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.

JSL Django Sitemap Generator

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 settings.py 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.

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.

Key Features

Powerful features that make sitemap generation effortless and efficient

Automatic Detection

Automatically detects changes in Django URL configuration and reloads new configuration without manual intervention.

Highly Configurable

Customize protocol, change frequency, priority, and include/exclude specific apps and URL patterns.

SEO Optimized

Generates SEO-friendly sitemaps compatible with Google, Bing, Yahoo, and other search engines.

Easy Integration

Simple installation and integration with existing Django projects. Minimal configuration required.

URL Pattern Support

Supports both named URLs and URL patterns. Automatically handles URL pattern formatting.

Performance Optimized

Efficient sitemap generation with minimal overhead. Fast processing even for large Django projects.

Installation & Setup

Get started with JSL Django Sitemap in just a few simple steps

1

Install from PyPI

pip install jsl-django-sitemap
2

Add to INSTALLED_APPS

INSTALLED_APPS = [
    # ...
    'django.contrib.sitemaps',
]
3

Configure Settings

JSL_DJANGO_SITEMAP_SETTINGS = {
    "ENABLE": True,
    "FETCH_URL_FROM": "name",
    "INCLUDE_APPS": ("ALL",),
    "IGNORE_URL_PATTERNS": (".*/api/v1/.*",)
}
4

Add URL Pattern

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

# Configure sitemap settings
sitemaps.get("static").protocol = 'https'
sitemaps.get("static").changefreq = 'weekly'
sitemaps.get("static").priority = 1

# Add to urlpatterns
path('sitemap.xml', sitemap, {'sitemaps': sitemaps}, 
     name='django.contrib.sitemaps.views.sitemap'),

Configuration Options

Customize your sitemap generation with powerful configuration options

Settings Configuration

ENABLE

Enable or disable sitemap generation

"ENABLE": True

FETCH_URL_FROM

Choose between "name" or "pattern" for URL generation

"FETCH_URL_FROM": "name"

INCLUDE_APPS

Specify which apps to include in sitemap

"INCLUDE_APPS": ("ALL",) // or ("myapp1", "myapp2")

IGNORE_URL_PATTERNS

Regex patterns to exclude from sitemap

"IGNORE_URL_PATTERNS": (".*/api/v1/.*",)

Sitemap Properties

protocol

Set the protocol for URLs (http/https)

sitemaps.get("static").protocol = 'https'

changefreq

How often the page changes

sitemaps.get("static").changefreq = 'weekly'

priority

Page priority relative to other pages (0.0 to 1.0)

sitemaps.get("static").priority = 1

Usage Examples

See how to implement JSL Django Sitemap in different scenarios

Basic Implementation

# urls.py
from django.contrib import admin
from django.urls import path
from jsl_django_sitemap.views import sitemaps
from django.contrib.sitemaps.views import sitemap

urlpatterns = [
    path('admin/', admin.site.urls),
    path('sitemap.xml', sitemap, {'sitemaps': sitemaps}, 
         name='django.contrib.sitemaps.views.sitemap'),
]

Advanced Configuration

# settings.py
JSL_DJANGO_SITEMAP_SETTINGS = {
    "ENABLE": True,
    "FETCH_URL_FROM": "name",
    "INCLUDE_APPS": ("blog", "shop", "pages"),
    "IGNORE_URL_PATTERNS": (
        ".*/api/.*",
        ".*/admin/.*",
        ".*/private/.*"
    )
}

# urls.py
sitemaps.get("static").protocol = 'https'
sitemaps.get("static").changefreq = 'daily'
sitemaps.get("static").priority = 0.9

View Generated Sitemap

After setup, start your development server and visit:

http://127.0.0.1:8000/sitemap.xml

Why Choose JSL Django Sitemap?

Experience the benefits of automated, SEO-friendly sitemap generation

Time Saving

Automatically generates sitemaps without manual intervention, saving hours of development time.

SEO Optimized

Improves search engine indexing and helps your website rank better in search results.

Highly Configurable

Customize every aspect of sitemap generation to match your specific requirements.

Easy Integration

Simple installation and minimal configuration required for existing Django projects.

URL Pattern Support

Supports both named URLs and URL patterns with automatic formatting and processing.

Performance Optimized

Efficient processing with minimal overhead, even for large Django projects with many URLs.