Eleventy Plugin Baseline

A magic carpet ride

Table of Contents

sitemap-core

Note: The options API is still evolving; expect tweaks as the project grows.

What it does

sitemap-core generates XML sitemaps via virtual templates. In single-language mode, it produces one sitemap at /sitemap.xml. In multilingual mode, it produces per-language sitemaps (/en/sitemap.xml, /nl/sitemap.xml, etc.) plus a sitemap index at /sitemap.xml. Every page gets computed sitemap defaults so you can control inclusion from front matter.

Defaults

  • Template: enabled (/sitemap.xml).
  • Per-page computed data: page.sitemap with { ignore, changefreq, priority, lastmod }.
  • Exclusion rules: a page is excluded if site.noindex is true (suppresses the entire sitemap), noindex: true in front matter, sitemap.ignore: true, or eleventyExcludeFromCollections: true.
  • lastmod: uses sitemap.lastmod from front matter, falls back to item.date.
  • Layout: null for the sitemap template; excluded from collections.

Options

Option Type Default Description
enableSitemapTemplate boolean true Toggle the built-in sitemap virtual template.

How it works

  1. Computed sitemap data.

    Adds eleventyComputed.page.sitemap to every page. This merges the page's noindex state, any sitemap: front matter fields, and site-level noindex into a single object the templates can read.

  2. Single-language sitemap.

    When the site is not multilingual, registers one virtual template at /sitemap.xml. It loops collections.all, filters out excluded pages, and emits a <urlset> with <loc>, optional <lastmod>, optional <changefreq>, and optional <priority>.

  3. Multilingual sitemaps.

    When multilingual: true and a languages map is set, registers a sitemap for each language (e.g. /en/sitemap.xml) filtered to pages matching that language, plus a sitemap index at /sitemap.xml that points to each per-language sitemap. Hreflang alternates are rendered as <xhtml:link> entries using collections.translationsMap.

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: true in front matter excludes the page from the sitemap and emits a robots meta tag (via head-core).
  • sitemap.ignore: true is sitemap-only exclusion — the page still renders and can be indexed.
  • eleventyExcludeFromCollections: true keeps the page out of collections and therefore out of the sitemap.

Tips

  • Set site.noindex: true in _data/site.js to suppress the sitemap entirely — the template outputs an empty <urlset>.
  • Search engines treat changefreq and priority as hints. Set them sparingly.
  • For lastmod, provide a date in front matter; without one, item.date (the file date) is used.
  • URLs in the sitemap are absolutized via htmlBaseUrl using site.url + pathPrefix. Keep site.url origin-only.
  • See Sitemaps & Drafts for end-to-end usage.

Peer deps

None.

Previous: navigator-core