Django. Generating an html sitemap

The xml sitemap was generated according to this guide https://docs.djangoproject.com/ja/1.9/ref/contrib/sitemaps/, however, there is no indication of creating an html sitemap. Does django have such a generation mechanism for html?

Author: while1pass, 2016-06-24

1 answers

Yes, you can. (though I can't even guess why you need it)

Take a look at the definition of the sitemap url:

views.sitemap(request, sitemaps, section=None, template_name='sitemap.xml', content_type='application/xml')

You can pass the template there as template_name and the generated content_type. Accordingly, you need to write your own template, for example, html_sitemam.html based on sitemap.xml from django

Next, you need to add to urls.py something like the following

[
    # ...
    url(r'^sitemap\.html$', sitemap, {'sitemaps': sitemaps, 'template_name': 'html_sitemap.html', 'content_type': 'text/html'})
]
 2
Author: FeroxTL, 2016-06-30 16:37:33