Create sitemap.xml

This commit is contained in:
Helen Chong 2024-08-20 14:49:11 +08:00
parent 4c944c16d7
commit 82df281cfb
2 changed files with 16 additions and 1 deletions

View File

@ -7,4 +7,4 @@ Disallow:
{{ robots.txt }}
Sitemap: {{ sitemeta.siteUrl }}/sitemap/
Sitemap: {{ sitemeta.siteUrl }}/sitemap.xml

15
src/sitemap.xml.njk Normal file
View File

@ -0,0 +1,15 @@
---
permalink: sitemap.xml
eleventyExcludeFromCollections: true
---
<?xml version="1.0" encoding="utf-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{% for item in collections.all -%}
<url>
<loc>{{ sitemeta.siteUrl + item.url | url }}</loc>
<lastmod>{% if item.updated %}{{ item.updated.toISOString() }}{% else %}{{ item.date.toISOString() }}{% endif %}</lastmod>
<changefreq>{{ item.data.sitemap.changefreq | default("monthly") }}</changefreq>
<priority>{{ item.data.sitemap.priority | default(0.5) }}</priority>
</url>
{%- endfor %}
</urlset>