How to make a sitemap for your website in Pelican.
First, prepare a jinja template for your site map.
sitemap.html
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{% for article in articles %}
<url>
<loc>{{ SITEURL }}/{{ article.url }}</loc>
<priority>0.8</priority>
</url>
{% for translation in article.translations %}
<url>
<loc>{{ SITEURL }}/{{ translation.url }}</loc>
<priority>0.8</priority>
</url>
{% endfor %}
{% endfor %}
{% for page in pages %}
<url>
<loc>{{ SITEURL }}/{{ page.url }}</loc>
<priority>1.0</priority>
</url>
{% for translation in page.translations %}
<url>
<loc>{{ SITEURL }}/{{ translation.url }}</loc>
<priority>1.0</priority>
</url>
{% endfor %}
{% endfor %}
</urlset>
Place the template in the templates directory of your theme, just like any other HTML template.
Then add the following settings to your config file:
DIRECT_TEMPLATES = ('index', 'tags', 'categories', 'archives', 'sitemap')
If you generate HTML after the above settings, sitemap.The xml will be generated.
Recommended Posts