diff --git a/hpst/sitemaps.py b/hpst/sitemaps.py new file mode 100644 index 0000000..b09d317 --- /dev/null +++ b/hpst/sitemaps.py @@ -0,0 +1,23 @@ +# sitemaps.py +from django.contrib import sitemaps +from django.urls import reverse + +class StaticViewSitemap(sitemaps.Sitemap): + priority = 0.5 + changefreq = 'daily' + + def items(self): + return ['index', + 'lamatour', + 'wildnispaedagogik', + 'externereferentin', + 'kinderfreizeit', + 'honigmassage', + 'psychologischeberatung', + 'pflanzenheilkunde', + 'ohrakupunktur', + 'impressum',] + + def location(self, item): + return reverse(item) + diff --git a/hpst/templates/robots.txt b/hpst/templates/robots.txt new file mode 100644 index 0000000..935d5d9 --- /dev/null +++ b/hpst/templates/robots.txt @@ -0,0 +1,5 @@ +User-Agent: * + +Disallow: + +Sitemap: https://www.sinnes-tau.de/sitemap.xml diff --git a/hpst/urls.py b/hpst/urls.py index 5721cb8..8899245 100644 --- a/hpst/urls.py +++ b/hpst/urls.py @@ -1,10 +1,17 @@ from django.urls import path from django.views.generic.base import RedirectView from django.contrib.staticfiles.storage import staticfiles_storage - +#Sitemaps & robots +from django.contrib.sitemaps.views import sitemap +from .sitemaps import StaticViewSitemap +from django.views.generic.base import TemplateView from . import views +sitemaps = { + 'static': StaticViewSitemap, +} + urlpatterns = [ path('', views.index, name='index'), path('index', views.index, name='index'), @@ -24,6 +31,9 @@ urlpatterns = [ "favicon.ico", RedirectView.as_view(url=staticfiles_storage.url("img/favicon.ico")), ), + path('sitemap.xml', sitemap, {'sitemaps': sitemaps}, + name='django.contrib.sitemaps.views.sitemap'), + path("robots.txt",TemplateView.as_view(template_name="robots.txt", content_type="text/plain")), #path('therapien.html',views.index, name='therapien'), #path('kontakt.html',views.index, name='kontakt'), #path(r'termine/.*',views.index, name='termine'), diff --git a/sinnestau/settings.py b/sinnestau/settings.py index b148e56..4245641 100644 --- a/sinnestau/settings.py +++ b/sinnestau/settings.py @@ -41,6 +41,7 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'django.contrib.sitemaps', 'djmoney', 'hpst', ]