---
title: 'Sitemaps and Drafts'
description: 'Control sitemap entries and drafts in Baseline: set per-page sitemap fields, apply noindex, and see how drafts behave in dev versus build.'
slug: 'sitemaps-and-drafts'
type: 'article'
date: 2026-01-25T00:00:00.000Z
lang: 'en'
url: 'https://www.eleventy-baseline.dev/docs/feature-guide/sitemaps-and-drafts/'
---

Control which pages end up in your sitemap, and let work-in-progress pages live alongside published ones without leaking into production. By the end you'll have per-page sitemap controls, a working `noindex` story, and a draft workflow that behaves differently in dev and build, the way you'd want.

Two terms used below:

- **Sitemap index.** The root `sitemap.xml` that lists per-language sitemaps when multilingual is on.
- **Drafts preprocessor.** The build-time hook Baseline registers to drop `draft: true` pages from production builds (and only from production builds).

---

## What you will build

- Pages that appear in `sitemap.xml`, and pages that don't.
- Per-page sitemap controls: `ignore`, `changefreq`, `priority`, `lastmod`.
- Draft pages that render in dev and quietly disappear in production.

---

## Prerequisites

- Baseline installed and loaded (defaults keep the sitemap on).
- Set `settings.url` to your production URL for correct sitemap and canonical links (use localhost while testing).
- `package.json` with `"type": "module"` and the `dev`/`build` scripts:
  ```json
  {
  	"name": "simple-baseline-site",
  	"type": "module",
  	"scripts": {
  		"start": "rimraf dist/ && npx @11ty/eleventy --serve",
  		"build": "rimraf dist/ && cross-env ELEVENTY_ENV=production npx @11ty/eleventy"
  	}
  }
  ```

---

## 1) Ensure the sitemap module is on (default)

Sitemap is on by default, so the eleventy.config.js from the previous tutorial is enough - no new options needed:

```js
import baseline, { config as baselineConfig } from '@apleasantview/eleventy-plugin-baseline';
import settings from './src/_data/settings.js';

/** @param {import("@11ty/eleventy").UserConfig} eleventyConfig */
export default async function (eleventyConfig) {
	await eleventyConfig.addPlugin(
		baseline(settings, {
			head: {
				titleSeparator: ' | ',
				showGenerator: true
			}
		})
	);
}

export const config = baselineConfig;
```

---

## 2) Page with sitemap controls

Create `src/content/pages/sitemap-demo.md`:

```md
---
title: 'Sitemap Demo'
slug: 'sitemap-demo'
description: 'Control sitemap entries.'
layout: 'layouts/base.njk'
sitemap:
  changefreq: 'weekly'
  priority: 0.7
  lastmod: 2024-01-01
---

This page stays in the sitemap with custom frequency, priority, and lastmod.
```

`changefreq`, `priority`, and `lastmod` are hints, not directives. Search engines treat them as suggestions, so adjust sparingly.

---

## 3) Noindex (site-wide and per-page)

Three knobs, in widening order of scope:

- Site-wide: set `noindex: true` in `_data/settings.js`. The whole sitemap is skipped.
- Per-page: set `noindex: true` in front matter. The page renders a `robots` noindex tag and drops out of the sitemap.
- Sitemap-only: use `sitemap: { ignore: true }` when the page should render normally but stay out of the sitemap.

  ```yaml
  sitemap:
    ignore: true
  eleventyExcludeFromCollections: true
  ```

  Two flags, two scopes worth distinguishing:
  - `sitemap: { ignore: true }` removes the page from the sitemap; the page still renders.
  - `eleventyExcludeFromCollections: true` keeps the page out of collections, and (because the sitemap reads from collections) out of the sitemap too.

---

## 4) Drafts

Add `draft: true` in front matter:

```yaml
draft: true
```

- In dev (`npm start`): drafts render normally.
- In build (`npm run build`, which sets `ELEVENTY_ENV=production`): drafts are skipped.
- Baseline registers its own drafts preprocessor. If you already have one, yours wins; Baseline's is guarded against double-registration.

---

## 5) Run and inspect

```bash
npm start
```

- Open pages normally.
- Check `dist/sitemap.xml` while dev runs. It's emitted, drafts included.
- Draft pages render in dev and show up in the dev sitemap. They drop out as soon as you build for production, since `npm run build` sets `ELEVENTY_ENV=production`.

---

## 6) Production build

Change `URL` in `.env` to an absolute URL. On a deployed site that's your real production URL; for this exercise, any absolute URL (e.g. `https://www.example.com/`) works to verify the output. Then run:

```bash
npm run build
```

Then inspect `dist/sitemap.xml`. A few things should be missing:

- Pages with `sitemap.ignore: true`.
- Every entry, if site-wide `noindex: true` is set.
- Anything marked `draft: true`.
- Reset `URL` in `.env` to "http://localhost:8080/".

---

## 7) Multilingual note

When multilingual is on, Baseline emits a per-language sitemap (`/en/sitemap.xml`, `/nl/sitemap.xml`, and so on) plus a sitemap index at the root. The per-page `ignore`, `noindex`, and `draft` rules apply to each entry just the same.

---

## Next steps

- Keep `settings.url` accurate in production, and set `pathPrefix` if you deploy under a subpath.
- Use drafts freely for in-progress content. Just remember they reappear in dev.
- Set defaults at the data layer: `_data/sitemap.js` for site-wide sitemap defaults, or directory data (e.g. `posts.11tydata.js`) to apply `sitemap` settings across a folder.
- The [[sitemap | sitemap module reference]] has the full option list.
