-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add multi-level nesting support to sitemap.xml
Fixes #1481.
- Loading branch information
Showing
1 changed file
with
16 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |