sitemap.xml

 1---
 2layout: null
 3sitemap:
 4  exclude: 'yes'
 5---
 6<?xml version="1.0" encoding="UTF-8"?>
 7<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
 8  {% for post in site.posts %}
 9    {% unless post.published == false %}
10    <url>
11      <loc>{{ site.url }}{{ post.url }}/</loc>
12      {% if post.sitemap.lastmod %}
13        <lastmod>{{ post.sitemap.lastmod | date: "%Y-%m-%d" }}</lastmod>
14      {% elsif post.date %}
15        <lastmod>{{ post.date | date_to_xmlschema }}</lastmod>
16      {% else %}
17        <lastmod>{{ site.time | date_to_xmlschema }}</lastmod>
18      {% endif %}
19      {% if post.sitemap.changefreq %}
20        <changefreq>{{ post.sitemap.changefreq }}</changefreq>
21      {% else %}
22        <changefreq>monthly</changefreq>
23      {% endif %}
24      {% if post.sitemap.priority %}
25        <priority>{{ post.sitemap.priority }}</priority>
26      {% else %}
27        <priority>0.7</priority>
28      {% endif %}
29    </url>
30    {% endunless %}
31  {% endfor %}
32  {% for page in site.pages %}
33    {% unless page.sitemap.exclude == "yes" %}
34    <url>
35      <loc>{{ site.url }}{{ page.url | remove: "index.html" }}</loc>
36      {% if page.sitemap.lastmod %}
37        <lastmod>{{ page.sitemap.lastmod | date: "%Y-%m-%d" }}</lastmod>
38      {% elsif page.date %}
39        <lastmod>{{ page.date | date_to_xmlschema }}</lastmod>
40      {% else %}
41        <lastmod>{{ site.time | date_to_xmlschema }}</lastmod>
42      {% endif %}
43      {% if page.sitemap.changefreq %}
44        <changefreq>{{ page.sitemap.changefreq }}</changefreq>
45      {% else %}
46        <changefreq>monthly</changefreq>
47      {% endif %}
48      {% if page.sitemap.priority %}
49        <priority>{{ page.sitemap.priority }}</priority>
50      {% else %}
51        <priority>0.5</priority>
52      {% endif %}
53    </url>
54    {% endunless %}
55  {% endfor %}
56</urlset>