Sitemap XML
OLDP provides an XML sitemap to help search engines discover and index legal documents. The sitemap is built using Django’s sitemaps framework.
Available URLs
URL |
Description |
|---|---|
|
Sitemap index listing all section sitemaps |
|
All court decisions |
|
All courts |
|
All laws (latest version only) |
Sitemap sections
CaseSitemap (oldp/apps/cases/sitemaps.py)
Queryset: All cases ordered by
updated_date(descending), withcourtpre-fetched and list-view fields deferred.Priority: 1.0
Change frequency: daily
CourtSitemap (oldp/apps/courts/sitemaps.py)
Queryset: All courts ordered by
updated_date(descending).Priority: 0.6
Change frequency: default (not set)
LawSitemap (oldp/apps/laws/sitemaps.py)
Queryset: Laws where
book__latest=True, withcontentandfootnotesdeferred, ordered byupdated_date(descending).Priority: 0.9
Change frequency: default (not set)
Caching
Both the sitemap index and section sitemaps are cached for 24 hours (cache_page(86400)) to avoid expensive database queries on every request. See oldp/urls.py for the URL configuration.
robots.txt integration
The Sitemap: directive in oldp/assets/templates/robots.txt points search engine crawlers to the sitemap index. This is the standard mechanism for sitemap discovery (see sitemaps.org).
Pinging Google
After adding or updating content, you can notify Google about the updated sitemap:
.venv/bin/python manage.py ping_google /sitemap.xml
Adding a new sitemap section
Create a
sitemaps.pyfile in the app (e.g.,oldp/apps/myapp/sitemaps.py):from django.contrib.sitemaps import GenericSitemap from oldp.apps.myapp.models import MyModel class MyModelSitemap(GenericSitemap): def __init__(self): super().__init__( { "queryset": MyModel.objects.all().order_by("-updated_date"), "date_field": "updated_date", }, priority=0.5, )
Register the sitemap in
oldp/urls.pyby adding it to thesitemapsdict:from oldp.apps.myapp.sitemaps import MyModelSitemap sitemaps = { "court": CourtSitemap(), "case": CaseSitemap(), "law": LawSitemap(), "mymodel": MyModelSitemap(), }
The key (e.g.,
"mymodel") determines the section URL:/sitemap-mymodel.xml.
Key files
oldp/urls.py— sitemap URL configuration andsitemapsdictoldp/apps/cases/sitemaps.py— CaseSitemapoldp/apps/courts/sitemaps.py— CourtSitemapoldp/apps/laws/sitemaps.py— LawSitemapoldp/assets/templates/robots.txt— robots.txt withSitemap:directiveoldp/apps/homepage/tests/test_views.py— sitemap integration test