From ed415b0f10702536d22c5efc4b35e5feee07eac8 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Mon, 24 Feb 2020 18:51:50 +0000 Subject: [PATCH 1/2] Suggest a way to create a stable sitemap --- content/docs/guides/sitemap/contents.lr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/docs/guides/sitemap/contents.lr b/content/docs/guides/sitemap/contents.lr index bb34570d..4c06a702 100644 --- a/content/docs/guides/sitemap/contents.lr +++ b/content/docs/guides/sitemap/contents.lr @@ -38,7 +38,7 @@ skips hidden pages so those will not be generated out. {%- for page in [site.root] if page != this recursive %} {{ page|url(external=true) }} - {{- loop(page.children) }} + {{- loop(page.children|sort(attribute='path')) }} {%- endfor %} ``` @@ -63,7 +63,7 @@ create a `sitemap/contents.lr` file instead and use a template like {% for page in [site.root] if page.record_label recursive %}
  • {{ page.record_label }} {% if page.children %} - + {% endif %}
  • {% endfor %} From bf823cf48b30a68e52f7eb17d5caa6a648333dd2 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Wed, 26 Feb 2020 14:05:35 +0000 Subject: [PATCH 2/2] Added explanation about why sorting the sitemap can be useful --- content/docs/guides/sitemap/contents.lr | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/content/docs/guides/sitemap/contents.lr b/content/docs/guides/sitemap/contents.lr index 4c06a702..91433041 100644 --- a/content/docs/guides/sitemap/contents.lr +++ b/content/docs/guides/sitemap/contents.lr @@ -43,6 +43,11 @@ skips hidden pages so those will not be generated out. ``` +Sorting the page using `|sort(attribute='path')` is not mandatory, but can be +useful if you prefer to have stable builds, for instance if you use `git` to +version the generated page and would like a clean history or a meaningful diff +from the last build. + Note that because sitemaps need to have external URLs (with scheme and everything) you will need to configure the `url` of the site before the template starts working. For more information see [Project File