diff options
author | EuAndreh <eu@euandre.org> | 2020-12-26 11:51:25 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2020-12-26 11:56:15 -0300 |
commit | 155cd84d776f722380a4bdbe90555c0fb3e112df (patch) | |
tree | 70805e8256c33a10a36d19f85c334379babae2b1 | |
parent | _config.yml: Exclude locale/ from build (diff) | |
download | euandre.org-155cd84d776f722380a4bdbe90555c0fb3e112df.tar.gz euandre.org-155cd84d776f722380a4bdbe90555c0fb3e112df.tar.xz |
sitemap.xml: Simplify generation of sitemap.xml, include all collections
Diffstat (limited to '')
-rw-r--r-- | _config.yml | 9 | ||||
-rw-r--r-- | sitemap.xml | 70 |
2 files changed, 30 insertions, 49 deletions
diff --git a/_config.yml b/_config.yml index afdea8b..bf0220f 100644 --- a/_config.yml +++ b/_config.yml @@ -62,6 +62,15 @@ collections: output: true permalink: /screencast/:year/:month/:title:output_ext +all_collections: + - pages + - articles + - tils + - pastebins + - slides + - podcasts + - screencasts + t: description: en: "EuAndreh's website" diff --git a/sitemap.xml b/sitemap.xml index 050bdb4..2104d39 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -2,57 +2,29 @@ --- <?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"> - {% for post in site.posts %} - <url> - <loc>{{ site.url }}{{ post.url }}</loc> - {% assign versions=site.posts | where:"ref", post.ref %} - {% for version in versions %} - <xhtml:link rel="alternate" hreflang="{{ version.lang }}" href="{{ site.url }}{{ version.url }}" /> - {% endfor %} - <lastmod>{{ post.date | date_to_xmlschema }}</lastmod> - <changefreq>monthly</changefreq> - </url> - {% endfor %} - - {% for page in site.pages %} - <url> - <loc>{{ site.url }}{{ page.url }}</loc> + {% for coll in site.all_collections %} + {% for page in site[coll] %} + {% comment %} + page ref is nil for generated pages, such + as post.html.1.txt code snippets + {% endcomment %} {% if page.ref != nil %} - {% assign versions=site.pages | where:"ref", page.ref %} - {% for version in versions %} - <xhtml:link rel="alternate" hreflang="{{ version.lang }}" href="{{ site.url }}{{ version.url }}" /> - {% endfor %} + <url> + <loc>{{ site.url }}{{ page.url }}</loc> + {% assign ref=page.ref %} + {% if page.ref == 'root' %} + {% assign ref='index' %} + {% endif %} + {% assign versions=site[coll] | where:"ref", ref %} + {% for version in versions %} + <xhtml:link rel="alternate" hreflang="{{ version.lang }}" href="{{ site.url }}{{ version.url }}" /> + {% endfor %} + {% if page.date != nil %} + <lastmod>{{ page.updated_at | default: page.date | date_to_xmlschema }}</lastmod> + {% endif %} + <changefreq>monthly</changefreq> + </url> {% endif %} - <changefreq>monthly</changefreq> - </url> - {% endfor %} - - {% for pastebin in site.pastebins %} - <url> - <loc>{{ site.url }}{{ pastebin.url }}</loc> - <changefreq>yearly</changefreq> - </url> - {% endfor %} - - {% for til in site.tils %} - <url> - <loc>{{ site.url }}{{ til.url }}</loc> - {% assign versions=site.tils | where:"ref", til.ref %} - {% for version in versions %} - <xhtml:link rel="alternate" hreflang="{{ version.lang }}" href="{{ site.url }}{{ version.url }}" /> - {% endfor %} - <changefreq>monthly</changefreq> - </url> - {% endfor %} - - {% for slide in site.slides %} - <url> - <loc>{{ site.url }}{{ slide.url }}</loc> - {% assign versions=site.slides | where:"ref", slide.ref %} - {% for version in versions %} - <xhtml:link rel="alternate" hreflang="{{ version.lang }}" href="{{ site.url }}{{ version.url }}" /> {% endfor %} - <changefreq>monthly</changefreq> - </url> {% endfor %} </urlset> |