diff --git a/pyproject.toml b/pyproject.toml index 6166494..e54bd50 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] dependencies = [ - "django~=5.2.12", + "django~=5.2.13", "django-braces", "django-debug-toolbar", "django-environ", @@ -18,7 +18,7 @@ description = "Spokane Python Community" dynamic = ["version"] keywords = ["django"] license = {file = "LICENSE"} -name = "my_django_project" +name = "SpokanePythonCommunity" readme = "README.md" requires-python = ">=3.12" diff --git a/src/django_project/core/settings.py b/src/django_project/core/settings.py index 21fe367..5a4fe92 100644 --- a/src/django_project/core/settings.py +++ b/src/django_project/core/settings.py @@ -54,6 +54,7 @@ "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", + "django.contrib.sitemaps", # third party apps "django_extensions", "django_filters", diff --git a/src/django_project/core/urls/urls.py b/src/django_project/core/urls/urls.py index 6cfcfe9..30700c5 100644 --- a/src/django_project/core/urls/urls.py +++ b/src/django_project/core/urls/urls.py @@ -17,12 +17,14 @@ from core.views import robots_txt from django.conf import settings from django.contrib import admin +from django.contrib.sitemaps.views import sitemap from django.urls import include, path from drf_spectacular.views import ( SpectacularAPIView, SpectacularRedocView, SpectacularSwaggerView, ) +from web.sitemaps import sitemaps urlpatterns = [ # Django provided URLs @@ -35,8 +37,9 @@ path("rest/schema/", SpectacularAPIView.as_view(), name="schema"), path("rest/swagger/", SpectacularSwaggerView.as_view(url_name="schema"), name="swagger"), path("rest/redoc/", SpectacularRedocView.as_view(url_name="schema"), name="redoc"), - # project level URLs + # SEO URLs path("robots.txt", robots_txt), + path("sitemap.xml", sitemap, {"sitemaps": sitemaps}, name="django.contrib.sitemaps.views.sitemap"), # URLs to local apps path("", include("web.urls", namespace="web")), ] diff --git a/src/django_project/core/views.py b/src/django_project/core/views.py index dcdb286..0a8b28c 100644 --- a/src/django_project/core/views.py +++ b/src/django_project/core/views.py @@ -12,4 +12,5 @@ def robots_txt(request) -> HttpResponse: Disallow: /__debug__/ Disallow: /accounts/ Disallow: /admin/ +Sitemap: https://spokanepython.com/sitemap.xml """ diff --git a/src/django_project/web/sitemaps.py b/src/django_project/web/sitemaps.py new file mode 100644 index 0000000..b849f64 --- /dev/null +++ b/src/django_project/web/sitemaps.py @@ -0,0 +1,19 @@ +from django.contrib.sitemaps import Sitemap + + +class StaticViewSitemap(Sitemap): + """Sitemap for static pages.""" + + priority = 1.0 + changefreq = "daily" + + def items(self) -> list[str]: + return ["/"] + + def location(self, item: str) -> str: + return item + + +sitemaps = { + "static": StaticViewSitemap, +} diff --git a/src/django_project/web/templates/web/full/index.html b/src/django_project/web/templates/web/full/index.html index ce0bbe7..fed86b3 100644 --- a/src/django_project/web/templates/web/full/index.html +++ b/src/django_project/web/templates/web/full/index.html @@ -23,11 +23,25 @@ - + + + + + + + + + +