Creating a simple Sitemap for Github Pages (Jekyll) powered site

31 May 2019 Tutorial #github pages #jekyll #sitemap

Today I decided to create a simple sitemap for my blog and upload it to Google Search Console. I opened WebStorm, pulled changes from GitHub and created a new file named sitemap.xml in blog root directory.

I found a sitemap protocol documentation and created something that looks like sitemap using built-in Jekyll language - Liquid.


---
---
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <url>
        <loc>{{site.url}}</loc>
        <changefreq>weekly</changefreq>
        <priority>1</priority>
    </url>

    {% for post in site.posts %}
    <url>
        <loc>{{site.url}}{{post.url}}</loc>
        <lastmod>{{post.date | date_to_xmlschema}}</lastmod>
        <priority>0.9</priority>
    </url>
    {% endfor %}
</urlset>

It can be extended by adding subpages etc.