sitemap.xml and robots.txt are the two entry points search engines use to crawl a site. xfm-plugin-sitemap walks every document at the end of each build and writes both files, with no plugin-level options at all.
What it solves
Hand-maintained sitemaps go stale and miss pages. This one is generated directly from site.documents, so the URL set always matches what was actually built. URLs are made absolute from site.url and site.base, which keeps subpath deployments correct. The matching robots.txt automatically gains a Sitemap: line pointing at the sitemap once site.url is configured, so the two files never drift apart.
Install and configure
npm i -D xfm-plugin-sitemapInstall and it works — the plugin has no options of its own. Everything it needs comes from the site basics (see configuration):
// xfm.config.mjs
export default {
site: {
url: 'https://xfm0797.github.io',
base: '', // e.g. '/blog' for subpath deployments
},
};Output and fields
Two files per build:
sitemap.xml: each<url>carries an absolute<loc>; pages withupdated(ordate) in front-matter get a<lastmod>; pages that declare aweightget a<priority>computed as1 - weight/100, clamped to the 0.1–1 range and printed with one decimal.robots.txt:User-agent: *withAllow: /, plusSitemap: <absolute url>whensite.urlis set.
Set sitemap: false in a page's front-matter to drop it — handy for about pages and tag aggregates you would rather not have crawled individually.
Notes
lastmodusesupdated || date; pages with neither date simply omit the field.sitemap: falseonly removes a page from the sitemap — it does not prevent indexing. For that, combine the seo plugin or anoindexmeta in your theme.- The xfmpress site itself runs this plugin; both files regenerate on every build. See SEO and site search.
Comments