Created
September 10, 2023 20:33
-
-
Save magician11/bdf9dcf68a0e0b6a1f3a7932c6c46bf1 to your computer and use it in GitHub Desktop.
sitemap.xml and robots.txt for 11ty (Eleventy)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
eleventyExcludeFromCollections: true | |
eleventyComputed: | |
permalink: "{{ site.robots }}" | |
--- | |
Sitemap: {{ site.baseUrl + site.siteMap }} | |
User-agent: * | |
Disallow: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"baseUrl": "https://example.com", | |
"robots": "/robots.txt", | |
"siteMap": "/sitemap.xml" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
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 %} | |
<url> | |
<loc>{{ site.baseUrl }}{{ page.url | url }}</loc> | |
<lastmod>{{ page.date.toISOString() }}</lastmod> | |
</url> | |
{% endfor %} | |
</urlset> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Place
site.json
in the_data
directory, and placerobots.txt.njk
andsitemap.njk
at the root of the project.