Add sitemap.xml
This commit is contained in:
parent
4a517aecc1
commit
096ff9f3de
@ -12,6 +12,11 @@ module.exports = function(eleventyConfig) {
|
|||||||
return DateTime.fromJSDate(dateObj).toFormat("dd LLL yyyy");
|
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
|
// only content in the `posts/` directory
|
||||||
eleventyConfig.addCollection("posts", function(collection) {
|
eleventyConfig.addCollection("posts", function(collection) {
|
||||||
return collection.getAllSorted().filter(function(item) {
|
return collection.getAllSorted().filter(function(item) {
|
||||||
|
1
404.md
1
404.md
@ -1,6 +1,7 @@
|
|||||||
---
|
---
|
||||||
layout: layouts/home.njk
|
layout: layouts/home.njk
|
||||||
permalink: 404.html
|
permalink: 404.html
|
||||||
|
excludeFromSitemap: true
|
||||||
---
|
---
|
||||||
# Content not found.
|
# Content not found.
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
permalink: feed/feed.xml
|
permalink: feed/feed.xml
|
||||||
|
excludeFromSitemap: true
|
||||||
---
|
---
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||||
@ -23,4 +24,4 @@ permalink: feed/feed.xml
|
|||||||
<content type="html">{{ post.templateContent | htmlToAbsoluteUrls(absolutePostUrl) }}</content>
|
<content type="html">{{ post.templateContent | htmlToAbsoluteUrls(absolutePostUrl) }}</content>
|
||||||
</entry>
|
</entry>
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
</feed>
|
</feed>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
permalink: feed/.htaccess
|
permalink: feed/.htaccess
|
||||||
|
excludeFromSitemap: true
|
||||||
---
|
---
|
||||||
# For Apache, to show `{{ metadata.feed.filename }}` when browsing to directory /feed/ (hide the file!)
|
# For Apache, to show `{{ metadata.feed.filename }}` when browsing to directory /feed/ (hide the file!)
|
||||||
DirectoryIndex {{ metadata.feed.filename }}
|
DirectoryIndex {{ metadata.feed.filename }}
|
||||||
|
16
sitemap.xml.njk
Normal file
16
sitemap.xml.njk
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
permalink: /sitemap.xml
|
||||||
|
excludeFromSitemap: true
|
||||||
|
---
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||||
|
{%- for page in collections.all %}
|
||||||
|
{%- if not page.data.excludeFromSitemap %}
|
||||||
|
{% set absoluteUrl %}{{ page.url | url | absoluteUrl(metadata.url) }}{% endset %}
|
||||||
|
<url>
|
||||||
|
<loc>{{ absoluteUrl }}</loc>
|
||||||
|
<lastmod>{{ page.date | htmlDateString }}</lastmod>
|
||||||
|
</url>
|
||||||
|
{%- endif %}
|
||||||
|
{%- endfor %}
|
||||||
|
</urlset>
|
Loading…
Reference in New Issue
Block a user