V
V
Vladisus2015-05-17 00:56:37
Django
Vladisus, 2015-05-17 00:56:37

How to add already generated sitemap.xml?

There is already a ready-made sitemap.xml (nothing needs to be generated), how to make it available via /sitemap.xml?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
sim3x, 2015-05-17
@sim3x

nginx

location = /sitemap.xml {
root /path/to/xml
}

Z
zelsky, 2015-05-17
@zelsky

If I understand the question correctly.
Write in urls.
In the view

def sitemap():
     return render(request,'sitemap.xml',{})

A
aka0, 2015-05-17
@aka0

from django.contrib.sitemaps.views import x_robots_tag

@x_robots_tag
def xml_sitemap(request):
    sitemap_file = 'sitemap.xml'
    try:
        with open(sitemap_file) as file:
            return HttpResponse(file.read(), content_type='application/xml')
    except IOError:
        raise Http404

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question