Skip to content

Commit 0574107

Browse files
committed
sitemap.xml and robots.txt
1 parent f4d2c81 commit 0574107

4 files changed

Lines changed: 18 additions & 0 deletions

File tree

.eleventy.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,16 @@ module.exports = function (eleventyConfig) {
1717
const content = post.replace(/(<([^>]+)>)/gi, "");
1818
return content.substr(0, content.lastIndexOf(" ", 200)) + "...";
1919
});
20+
eleventyConfig.addFilter("dateToISOString", function (date) {
21+
return date.toISOString();
22+
});
2023

2124
// copy these files to the output directory
2225
// if the directories contain any template extensions (such as.html or .md),
2326
// be sure to add the directory to .eleventyignore
2427
eleventyConfig.addPassthroughCopy("img");
2528
eleventyConfig.addPassthroughCopy(".htaccess");
29+
eleventyConfig.addPassthroughCopy("robots.txt");
2630
eleventyConfig.addPassthroughCopy("asdoc");
2731
eleventyConfig.addPassthroughCopy("blog-examples");
2832
eleventyConfig.addPassthroughCopy("tourdejewel");

_includes/content-only.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{ content }}

robots.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Sitemap: /sitemap.xml

sitemap.liquid

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
permalink: /sitemap.xml
3+
eleventyExcludeFromCollections: true
4+
layout: content-only.html
5+
---
6+
<?xml version="1.0" encoding="utf-8"?>
7+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
8+
{% for page in collections.all %}<url>
9+
<loc>https://royale.apache.org{{ page.url | url }}</loc>
10+
<lastmod>{{ page.date | dateToISOString }}</lastmod>
11+
</url>{% endfor %}
12+
</urlset>

0 commit comments

Comments
 (0)