Sitemap in xml generated by this guide https://docs.djangoproject.com/ja/1.9/ref/contrib/sitemaps/ , however, there is no indication of the creation of html sitemap. Does jango have such a generation mechanism for html?
1 answer
Yes you can. (although I can’t even imagine why)
Take a look at the url definition of sitemap:
views.sitemap(request, sitemaps, section=None, template_name='sitemap.xml', content_type='application/xml') There you can pass the template as a template_name and the generated content_type. Accordingly, you need to write your 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'}) ] - Thanks, I will try. Sitemap for visitors, for this purpose - while1pass
- oneWhat is the last function argument introduced for - html_sitemap? - while1pass 3:51 pm
- Difficult to answer, do not use this parameter, apparently I incorrectly edited the code when I copied from the repository. Answer corrected - FeroxTL
- oneAnd the curly bracket needs to be transferred (we pass the kwargs dictionary), the URL will be the url (r '^ sitemap \ .html $', sitemap, {'sitemaps': sitemaps,' template_name ':' html_sitemap.html ',' content_type ':' text / html '}), - while1pass
- @ while1pass Accurately, as if I was responding at work, somehow missed this moment - FeroxTL
|