diff --git a/.eleventy.js b/.eleventy.js index b387b3c..9d6487d 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -12,6 +12,11 @@ module.exports = function(eleventyConfig) { return DateTime.fromJSDate(dateObj).toFormat("dd LLL yyyy"); }); + // https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string + eleventyConfig.addFilter('htmlDateString', (dateObj) => { + return DateTime.fromJSDate(dateObj).toFormat('yyyy-LL-dd'); + }); + // only content in the `posts/` directory eleventyConfig.addCollection("posts", function(collection) { return collection.getAllSorted().filter(function(item) { diff --git a/404.md b/404.md index a5465e4..c3d1080 100644 --- a/404.md +++ b/404.md @@ -1,6 +1,7 @@ --- layout: layouts/home.njk permalink: 404.html +excludeFromSitemap: true --- # Content not found. diff --git a/feed/feed.njk b/feed/feed.njk index 636c9c2..f889671 100644 --- a/feed/feed.njk +++ b/feed/feed.njk @@ -1,5 +1,6 @@ --- permalink: feed/feed.xml +excludeFromSitemap: true --- @@ -23,4 +24,4 @@ permalink: feed/feed.xml {{ post.templateContent | htmlToAbsoluteUrls(absolutePostUrl) }} {%- endfor %} - \ No newline at end of file + diff --git a/feed/htaccess.njk b/feed/htaccess.njk index 3318d60..8b4e0d9 100644 --- a/feed/htaccess.njk +++ b/feed/htaccess.njk @@ -1,5 +1,6 @@ --- permalink: feed/.htaccess +excludeFromSitemap: true --- # For Apache, to show `{{ metadata.feed.filename }}` when browsing to directory /feed/ (hide the file!) -DirectoryIndex {{ metadata.feed.filename }} \ No newline at end of file +DirectoryIndex {{ metadata.feed.filename }} diff --git a/sitemap.xml.njk b/sitemap.xml.njk new file mode 100644 index 0000000..d1745a3 --- /dev/null +++ b/sitemap.xml.njk @@ -0,0 +1,16 @@ +--- +permalink: /sitemap.xml +excludeFromSitemap: true +--- + + +{%- for page in collections.all %} +{%- if not page.data.excludeFromSitemap %} + {% set absoluteUrl %}{{ page.url | url | absoluteUrl(metadata.url) }}{% endset %} + + {{ absoluteUrl }} + {{ page.date | htmlDateString }} + +{%- endif %} +{%- endfor %} +