sitemap
INTERNAL_KEY: '_sitemap'
What it does
The sitemap module emits /sitemap.xml from your built pages. In single-language mode, one flat sitemap. With multilang active and more than one language configured, one sitemap per language at /<lang>/sitemap.xml plus a sitemap index at /sitemap.xml that points at each.
Any page can opt out from its front matter. The module resolves every page's entry once, into a computed _sitemap, and its own template reads that rather than deciding anything itself. You set sitemap; _sitemap is what Baseline made of it, and it is readable from any template as a summary of where the page stands.
The sitemap is rendered through virtual templates: synthetic templates Baseline injects into the build, not files you write. They use Eleventy's normal collection access (collections.all) and the same data cascade your pages do.
Active when
options.sitemap is truthy. Defaults to true. Set sitemap: false to skip the module entirely.
Lifecycle
- Build-time. Registers virtual templates: a single
/sitemap.xml, or per-language sitemaps plus an index if multilang is active. - Cascade-time. Computed
_sitemapresolves on every page from the cascade (itsignore,changefreq,priorityandlastmodfields).
The sitemap virtual templates set _internal: true so they do not get a page context. They are emitted as XML, not HTML, and the head module skips them.
How it works
- Compute
_sitemap. Registered aseleventyComputed._sitemap. Resolvesignore,changefreq,priorityandlastmodfrom cascade data, reading the author'ssitemapkey rather than writing to it. - Resolve language config. Reads
settings.languagesthroughnormalizeLanguageMap, the same helper the multilang module uses. - Register virtual templates.
- Single-language: one template at
/sitemap.xml. Loopscollections.all, filters excluded pages, emits<urlset>with<loc>, optional<lastmod>, optional<changefreq>, optional<priority>. - Multilingual: one template per language at
<lang>/sitemap.xml, plus a sitemap index template at/sitemap.xml. Per-language sitemaps include<xhtml:link>alternates for every translation sibling, sourced from the translation map.
- Single-language: one template at
Each virtual template sets _internal: true so the page-context registry skips it (it is not a real page). It also sets eleventyExcludeFromCollections: true so the sitemap does not list itself.
Defaults
- Sitemap output.
/sitemap.xmlin single-language mode, or/<lang>/sitemap.xmlplus/sitemap.xml(the index) when multilang is active with more than one language. A multilang site with a single language in the map keeps the flat sitemap. - Computed
_sitemap. Every page receives{ ignore, changefreq, priority, lastmod }.ignoreissitemap.ignore: trueor the page's resolved noindex,changefreqandprioritycome from your front matter and are otherwise unset, andlastmodissitemap.lastmodor the page's resolved modified date, absent when neither resolves. This is the mechanism, not a summary of it: the template reads this object and decides nothing of its own. - Exclusion rules. A page is dropped when its resolved
ignoreis true, wheneleventyExcludeFromCollections: true, or when it has nourl(apermalink: falserecord).ignorefolds innoindex: true,seo.noindex: true(which wins over it, including when it overrides it tofalse) andsitemap.ignore: true.settings.noindexempties the whole file in one go. changefreqandpriorityare emitted only when your front matter carries them undersitemap. Neither has a default, because a guessed value is a claim about your content that Baseline cannot make.
Settings
The sitemap module reads four keys on the settings argument. Full shape on Site settings.
| Key | Type | Used for |
|---|---|---|
settings.url |
string |
Building absolute <loc> entries. |
settings.noindex |
boolean |
When true, the sitemap file is still written but lists nothing. |
settings.languages |
object |
Drives per-language partitioning when multilang is active. Read through the same normalisation as the multilang module. |
settings.defaultLocale or settings.defaultLanguage |
string |
Which language files under the unprefixed URLs. Resolved through the same resolver the multilang module uses, so either key works. Without one, partitioning does not happen and you get the single flat sitemap. |
Options
| Option | Type | Default | Meaning |
|---|---|---|---|
sitemap |
boolean |
true |
Activate the module. Set false to skip it. |
Per-page sitemap controls
Set these in front matter:
sitemap:
ignore: true # exclude from sitemap (page still renders)
changefreq: weekly
priority: 0.8
lastmod: 2026-01-15
noindex: truein front matter, or underseo:, excludes the page from the sitemap and (because the head module reads the same field) emits arobotsmeta tag.sitemap.ignore: trueis sitemap-only exclusion. The page still renders and search engines can still index it.eleventyExcludeFromCollections: truekeeps the page out of all collections, includingcollections.all, so the sitemap never sees it.
lastmod uses sitemap.lastmod if you set it; otherwise the modified date Baseline resolved for the page, which is the last commit to touch the file unless your front matter says otherwise. Both arrive through _sitemap as finished strings, so the template formats nothing. See Dates.
Multilingual mode
When the multilang module is active and settings.languages has more than one entry, the layout switches automatically:
/en/sitemap.xml,/nl/sitemap.xml, etc.: one per language, listing only that language's pages plus hreflang alternates./sitemap.xml: a sitemap index pointing at each per-language sitemap.
Tips
- Set
settings.noindex: trueto empty the sitemap (useful for staging environments). The file is still written; it just lists no pages. - Search engines treat
changefreqandpriorityas hints. Set them sparingly, only where you actually have a useful answer. - Provide
lastmodin front matter when you want to override the freshness signal. Without one, the resolved modified date is used, and a page with no resolvable date gets no<lastmod>element rather than a wrong one. - URLs are absolutized via Eleventy's
HtmlBasePluginusingsettings.urlandpathPrefix. Keepsettings.urlorigin-only (no trailing path), and usepathPrefixfor sub-path deployments.
Peer deps
None.
See also
- Site settings for
url,noindex,languages. - multilang module for the language normalisation and translation map shared with this module.
- Page context for
_internal: true, the opt-out the virtual templates use. - Tutorial: sitemaps and drafts