diff --git a/eleventy.config.js b/eleventy.config.js index cde5502c..0cbe9e77 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -53,6 +53,7 @@ export default function (eleventyConfig) { eleventyConfig.addPassthroughCopy("src/assets/file"); eleventyConfig.addPassthroughCopy("src/assets/media"); eleventyConfig.addPassthroughCopy("src/static"); + eleventyConfig.addPassthroughCopy({ "src/static/robots.txt": "robots.txt" }); // Keep informal notes separate from the regular post collection. eleventyConfig.addCollection("ramblings", (collectionApi) => { @@ -91,6 +92,10 @@ export default function (eleventyConfig) { eleventyConfig.addFilter("currentYear", () => new Date().getFullYear()); + eleventyConfig.addFilter("absoluteUrl", (url, base) => { + return new URL(url, base).href; + }); + eleventyConfig.addFilter("newestUpdatedDate", (items = []) => { if (!items.length) return new Date(); diff --git a/src/_includes/layouts/base.njk b/src/_includes/layouts/base.njk index 009a68e8..799d5afb 100644 --- a/src/_includes/layouts/base.njk +++ b/src/_includes/layouts/base.njk @@ -8,7 +8,7 @@ - + @@ -18,6 +18,7 @@ + diff --git a/src/sitemap.njk b/src/sitemap.njk index 55c3bff9..6b19d8d2 100644 --- a/src/sitemap.njk +++ b/src/sitemap.njk @@ -9,8 +9,9 @@ {% for page in collections.all %} {% if page.url and not page.data.eleventyExcludeFromCollections %} - {{ site.url }}{{ page.url }} - {{ page.date | isoDate }} + {{ page.url | absoluteUrl(site.url) | escape }} + {% set lastmod = page.data.updated or page.data.date %} + {% if lastmod %}{{ lastmod | isoDate }}{% endif %} {% endif %} {% endfor %} diff --git a/src/static/robots.txt b/src/static/robots.txt index 16747ccc..069ee5e5 100644 --- a/src/static/robots.txt +++ b/src/static/robots.txt @@ -1,4 +1,4 @@ -Sitemap: https://www.h404bi.com/sitemap.xml - User-agent: * -Disallow: /drafts +Allow: / + +Sitemap: https://blog.never.pet/sitemap.xml