robots.txt && sitemap.xml

This commit is contained in:
Nikola Kubiczek 2021-09-20 22:19:59 +02:00
parent 350488e748
commit 5e0328f5b1
5 changed files with 67 additions and 2 deletions

View File

@ -72,6 +72,7 @@ class Announcement(models.Model):
class Meta: class Meta:
verbose_name = 'Ogłoszenie' verbose_name = 'Ogłoszenie'
verbose_name_plural = 'Ogłoszenia' verbose_name_plural = 'Ogłoszenia'
ordering = ['-created_at']
class UserManager(BaseUserManager): class UserManager(BaseUserManager):

4
app/templates/robots.txt Normal file
View File

@ -0,0 +1,4 @@
User-agent: *
Disallow: /admin
Sitemap: https://puchar.lo5.bielsko.pl/sitemap.xml

44
app/templates/sitemap.xml Normal file
View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://puchar.lo5.bielsko.pl</loc>
<priority>1.0</priority>
<changefreq>yearly</changefreq>
</url>
<url>
<loc>https://puchar.lo5.bielsko.pl/aktualnosci</loc>
<priority>0.9</priority>
<lastmod>{{ latest.created_at | date:"Y-m-d" }}</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
<loc>https://puchar.lo5.bielsko.pl/regulamin</loc>
<priority>0.8</priority>
<changefreq>never</changefreq>
</url>
<url>
<loc>https://puchar.lo5.bielsko.pl/zadania</loc>
<priority>0.8</priority>
<changefreq>yearly</changefreq>
</url>
<url>
<loc>https://puchar.lo5.bielsko.pl/wyniki</loc>
<priority>0.5</priority>
<changefreq>yearly</changefreq>
</url>
<url>
<loc>https://puchar.lo5.bielsko.pl/kontakt</loc>
<priority>0.7</priority>
<changefreq>never</changefreq>
</url>
<url>
<loc>https://puchar.lo5.bielsko.pl/login</loc>
<priority>0.6</priority>
<changefreq>never</changefreq>
</url>
<url>
<loc>https://puchar.lo5.bielsko.pl/rejestracja</loc>
<priority>0.6</priority>
<changefreq>never</changefreq>
</url>
</urlset>

View File

@ -1,6 +1,6 @@
from django.urls import path from django.urls import path
from .views import SignUpView, SubmitStudentsView, UpdateAccountView, ScoresRedirect, HomeView, NewsView, ScoresView, RulesView, TestsView, ContactView from .views import SignUpView, SubmitStudentsView, UpdateAccountView, ScoresRedirect, HomeView, NewsView, ScoresView, RulesView, TestsView, ContactView, RobotsView, SitemapView
urlpatterns = [ urlpatterns = [
path('', HomeView.as_view(), name='home'), path('', HomeView.as_view(), name='home'),
@ -13,5 +13,8 @@ urlpatterns = [
path('rejestracja/', SignUpView.as_view(), name='signup'), path('rejestracja/', SignUpView.as_view(), name='signup'),
path('konto/', UpdateAccountView, name='account'), path('konto/', UpdateAccountView, name='account'),
path('zgloszenie/', SubmitStudentsView, name='submission') path('zgloszenie/', SubmitStudentsView, name='submission'),
path('robots.txt', RobotsView.as_view()),
path('sitemap.xml', SitemapView.as_view())
] ]

View File

@ -144,3 +144,16 @@ class ContactView(TemplateView):
extra_context = { extra_context = {
'contact_page': 'is-active' 'contact_page': 'is-active'
} }
class RobotsView(TemplateView):
template_name = 'robots.txt'
content_type = 'text/plain'
class SitemapView(TemplateView):
template_name = 'sitemap.xml'
content_type = 'text/xml'
extra_context = {
'latest': Announcement.objects.first()
}