add sitemap and open graph
This commit is contained in:
parent
b836d38e70
commit
a07d1fc4e2
9 changed files with 176 additions and 0 deletions
34
hub/urls.py
34
hub/urls.py
|
@ -4,13 +4,40 @@ from django.conf.urls.static import static
|
|||
from django.contrib import admin
|
||||
from django.shortcuts import render
|
||||
from django.urls import path, include
|
||||
from django.contrib.sitemaps.views import sitemap
|
||||
from django.http import HttpResponse
|
||||
|
||||
|
||||
from hub.services.views.errors import bad_request, page_not_found, server_error
|
||||
from .sitemaps import (
|
||||
StaticSitemap,
|
||||
ServiceSitemap,
|
||||
OfferingSitemap,
|
||||
CloudProviderSitemap,
|
||||
ConsultingPartnerSitemap,
|
||||
)
|
||||
|
||||
|
||||
def robots_txt(request):
|
||||
content = """User-agent: *
|
||||
Allow: /
|
||||
Sitemap: https://serva.la/sitemap.xml
|
||||
"""
|
||||
return HttpResponse(content, content_type="text/plain")
|
||||
|
||||
|
||||
handler400 = "hub.services.views.errors.bad_request"
|
||||
handler404 = "hub.services.views.errors.page_not_found"
|
||||
handler500 = "hub.services.views.errors.server_error"
|
||||
|
||||
sitemaps = {
|
||||
"static": StaticSitemap,
|
||||
"services": ServiceSitemap,
|
||||
"offerings": OfferingSitemap,
|
||||
"providers": CloudProviderSitemap,
|
||||
"partners": ConsultingPartnerSitemap,
|
||||
}
|
||||
|
||||
urlpatterns = [
|
||||
path("admin/", admin.site.urls),
|
||||
path("", include("hub.services.urls")),
|
||||
|
@ -23,5 +50,12 @@ if settings.DEBUG:
|
|||
path("test-400/", lambda request: render(request, "400.html"), name="test_400"),
|
||||
path("test-404/", lambda request: render(request, "404.html"), name="test_404"),
|
||||
path("test-500/", lambda request: render(request, "500.html"), name="test_500"),
|
||||
path(
|
||||
"sitemap.xml",
|
||||
sitemap,
|
||||
{"sitemaps": sitemaps},
|
||||
name="django.contrib.sitemaps.views.sitemap",
|
||||
),
|
||||
path("robots.txt", robots_txt, name="robots_txt"),
|
||||
]
|
||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue