diff --git a/cookiecutter-django/{{cookiecutter.project_slug}}/core/settings.py b/cookiecutter-django/{{cookiecutter.project_slug}}/core/settings.py index 6e9a8e3..5cb5200 100644 --- a/cookiecutter-django/{{cookiecutter.project_slug}}/core/settings.py +++ b/cookiecutter-django/{{cookiecutter.project_slug}}/core/settings.py @@ -49,6 +49,7 @@ "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", + "django.contrib.sitemaps", ] MIDDLEWARE = [ diff --git a/cookiecutter-django/{{cookiecutter.project_slug}}/core/urls.py b/cookiecutter-django/{{cookiecutter.project_slug}}/core/urls.py index 083932c..e7f26c9 100644 --- a/cookiecutter-django/{{cookiecutter.project_slug}}/core/urls.py +++ b/cookiecutter-django/{{cookiecutter.project_slug}}/core/urls.py @@ -1,6 +1,10 @@ from django.contrib import admin +from django.contrib.sitemaps.views import sitemap from django.urls import path +sitemaps = {} + urlpatterns = [ path("admin/", admin.site.urls), + path("sitemap.xml", sitemap, {"sitemaps": sitemaps}, name="django.contrib.sitemaps.views.sitemap"), ] diff --git a/docs/python/django.rst b/docs/python/django.rst index c9cf983..473e303 100644 --- a/docs/python/django.rst +++ b/docs/python/django.rst @@ -51,6 +51,14 @@ URLs - Use hyphens as separators in `named URL patterns `__. - Use `Django REST Framework `__, instead of writing REST endpoints by hand. (See :doc:`preferences`.) +Sitemap +~~~~~~~ + +Public sites should serve a ``sitemap.xml`` file. + +- Do not set ``changefreq`` or ``priority``. (`"Google ignores priority and changefreq values." `__) +- Do not use ``django.contrib.sitemaps.ping_google()``. (`"Sitemaps ping endpoint is going away." `__) + .. _django-models: Models @@ -174,6 +182,8 @@ Using the template Remove, unless using ``django.contrib.admin``, ``django.contrib.auth``, ``django.contrib.messages`` or anonymous sessions (check for occurrences of ``session``). `django.contrib.staticfiles `__ (`how-to `__) Remove, unless the project contains static files. + `django.contrib.sitemaps `__ + Remove, if the application is private. (Added by the Cookiecutter template.) Then, make any corresponding changes to ``urls.py``, and ``MIDDLEWARE``, ``TEMPLATES``, ``STATIC_URL`` and ``AUTH_PASSWORD_VALIDATORS`` in ``settings.py``. `DATABASES `__