Last active
April 27, 2018 01:51
-
-
Save bminard/33785efed6ff1492bf54c1010c6f88d2 to your computer and use it in GitHub Desktop.
Generate an XML site map using Jekyll.
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
--- | |
layout: | |
permalink: /sitemap.xml | |
--- | |
<?xml version="1.0" encoding="UTF-8"?> | |
<urlset | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd | |
http://www.w3.org/1999/xhtml http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd" | |
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 }}{{ site.baseurl}}{{ post.url }}</loc> | |
<xhtml:link rel="alternate" hreflang="en" href="{{ site.url }}{{ site.baseurl}}{{ post.url }}" /> | |
{% if post.last_modified_at %} | |
<lastmod>{{ post.last_modified_at | date_to_xmlschema }}</lastmod> | |
{% else %} | |
<lastmod>{{ post.date | date_to_xmlschema }}</lastmod> | |
{% endif %} | |
</url> | |
{% endfor %} | |
{% for page in site.html_pages %} | |
<url> | |
<loc>{{ site.url }}{{ site.baseurl }}/{{ page.path }}</loc> | |
<xhtml:link rel="alternate" hreflang="en" href="{{ site.url }}{{ site.baseurl }}/{{ page.path }}" /> | |
</url> | |
{% endfor %} | |
</urlset> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment