DEV Community

Hilton Meyer
Hilton Meyer

Posted on • Originally published at hiltonmeyer.com on

7 3

Creating a sitemap in 11ty

In order to submit your site to search analytics you should have a sitemap of your content. Having this just makes it easier and quicker for the search engines to find and index your site content. So I went about find how to do this with 11ty. The base blog of 11ty has this built in so I made a few changes especially for the dates.

--------
permalink: /sitemap.xml
eleventyExcludeFromCollections: true
--------
<?xml version="1.0" encoding="utf-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{%- for page in collections.all %}
  {% set mappedUrl %}{{ metadata.url}}{{ page.url | url }}{% endset %}
  <url>
    <loc>{{ mappedUrl }}</loc>
    <lastmod>{{ page.date | htmlDateString }}</lastmod>
  </url>
{%- endfor %}
</urlset>

Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
winstonpuckett profile image
Winston Puckett

I new it was supposed to look like the RSS feed. Thanks for doing the work to figure out what the site map is supposed to look like

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay