Prevent some pages from search indexing

This commit is contained in:
Raphael Michel
2017-09-25 10:04:37 +02:00
parent ef3eee7873
commit 43fc498297
6 changed files with 36 additions and 4 deletions

View File

@@ -0,0 +1,26 @@
from django.http import HttpResponse
from django.views.decorators.cache import cache_page
class NoSearchIndexViewMixin:
def dispatch(self, request, *args, **kwargs):
resp = super().dispatch(request, *args, **kwargs)
resp['X-Robots-Tag'] = "noindex"
return resp
@cache_page(3600)
def robots_txt(request):
return HttpResponse(
"""User-agent: *
Disallow: */cart/*
Disallow: */checkout/*
Disallow: */order/*
Disallow: */locale/set*
Disallow: /control/
Disallow: /download/
Disallow: /redirect/
Disallow: /api/
Disallow: /download/
""", content_type='text/plain'
)