forked from 00dani/lemoncurry
Add a simple sitemap using django.contrib.sitemaps - there aren't a lot of pages to map so far so it's pretty basic ;)
This commit is contained in:
parent
f5f4a1d03f
commit
501c91bd12
3 changed files with 28 additions and 3 deletions
12
home/sitemaps.py
Normal file
12
home/sitemaps.py
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
from django.contrib import sitemaps
|
||||||
|
from django.urls import reverse
|
||||||
|
|
||||||
|
|
||||||
|
class HomeSitemap(sitemaps.Sitemap):
|
||||||
|
changefreq = 'daily'
|
||||||
|
|
||||||
|
def items(self):
|
||||||
|
return ('home:index',)
|
||||||
|
|
||||||
|
def location(self, item):
|
||||||
|
return reverse(item)
|
|
@ -60,6 +60,7 @@ INSTALLED_APPS = [
|
||||||
'django.contrib.auth',
|
'django.contrib.auth',
|
||||||
'django.contrib.contenttypes',
|
'django.contrib.contenttypes',
|
||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
|
'django.contrib.sitemaps',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,20 @@ Including another URLconf
|
||||||
from django.conf.urls import include, url
|
from django.conf.urls import include, url
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
|
import django.contrib.sitemaps.views as sitemap
|
||||||
|
from home.sitemaps import HomeSitemap
|
||||||
|
|
||||||
|
sections = {
|
||||||
|
'home': HomeSitemap,
|
||||||
|
}
|
||||||
|
maps = {'sitemaps': sections}
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^', include('home.urls')),
|
url('', include('home.urls')),
|
||||||
url(r'^.well-known/', include('wellknowns.urls')),
|
url('^.well-known/', include('wellknowns.urls')),
|
||||||
url(r'^admin/', admin.site.urls),
|
url('^admin/', admin.site.urls),
|
||||||
|
|
||||||
|
url(r'^sitemap\.xml$', sitemap.index, maps),
|
||||||
|
url(r'^sitemaps/(?P<section>.+)\.xml$', sitemap.sitemap, maps,
|
||||||
|
name='django.contrib.sitemaps.views.sitemap'),
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue