Navigation Menu

Skip to content

Commit

Permalink
Add multi-level nesting support to sitemap.xml
Browse files Browse the repository at this point in the history
Fixes #1481.
  • Loading branch information
waylan committed May 9, 2018
1 parent e5c2459 commit e714900
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
3 changes: 3 additions & 0 deletions docs/about/release-notes.md
Expand Up @@ -88,6 +88,9 @@ authors should review how [search and themes] interact.
* Update links to Python-Markdown library (#1360).
* Document how to generate manpages for MkDocs commands (#686).

## Version 0.17.4
* Bugfix: Add multi-level nesting support to sitemap.xml (#1482).

## Version 0.17.3 (2018-03-07)

* Bugfix: Set dependency `tornado>=4.1,<5.0` due to changes in 5.0 (#1428).
Expand Down
32 changes: 16 additions & 16 deletions mkdocs/templates/sitemap.xml
@@ -1,20 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{% for nav_item in nav %}
{% if nav_item.children %}
{% for nav_item in nav_item.children %}
{%- macro nav_item(item) -%}
{%- if item.children -%}
{%- for child in item.children -%}
{{ nav_item(child) }}
{%- endfor -%}
{%- else %}
<url>
<loc>{{ config.site_url }}{{ nav_item.abs_url }}</loc>
{% if nav_item.update_date %}<lastmod>{{nav_item.update_date}}</lastmod>{% endif %}
<loc>{% if item.canonical_url %}{{ item.canonical_url }}{% else %}{{ item.abs_url }}{% endif %}</loc>
{% if item.update_date %}<lastmod>{{item.update_date}}</lastmod>{% endif %}
<changefreq>daily</changefreq>
</url>
{% endfor %}
{% else %}
<url>
<loc>{{ config.site_url }}{{ nav_item.abs_url }}</loc>
{% if nav_item.update_date %}<lastmod>{{nav_item.update_date}}</lastmod>{% endif %}
<changefreq>daily</changefreq>
</url>
{% endif %}
{% endfor %}
{%- endif -%}
{%- endmacro -%}

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{%- for item in nav -%}
{{ nav_item(item) }}
{%- endfor %}
</urlset>

0 comments on commit e714900

Please sign in to comment.