Skip to content

Commit 8f504d7

Browse files
author
pavdmyt
committed
SEO: sitemap.xml and robots.txt added.
1 parent fb0fe76 commit 8f504d7

File tree

6 files changed

+73
-0
lines changed

6 files changed

+73
-0
lines changed

404.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
layout: page
33
title: 404
4+
sitemap:
5+
exclude: 'yes'
46
---
57

68
<h2 class="go-home">

css/main.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
22
# Only the main Sass file needs front matter (the dashes are enough)
3+
sitemap:
4+
exclude: 'yes'
35
---
46
@charset "utf-8";
57

feed.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
22
layout: null
3+
sitemap:
4+
exclude: 'yes'
35
---
46
<?xml version="1.0" encoding="UTF-8"?>
57
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">

index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
layout: page
33
title: Blog
44
subtitle: Hitchhiker's guid to web development
5+
sitemap:
6+
priority: 0.9
57
---
68

79
<ul class="list-posts">

robots.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
layout: null
3+
sitemap:
4+
exclude: 'yes'
5+
---
6+
User-agent: *
7+
Disallow:
8+
9+
Sitemap: {{ site.url }}/sitemap.xml

sitemap.xml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
layout: null
3+
sitemap:
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>

0 commit comments

Comments
 (0)