Eleventy Plugin Baseline

A magic carpet ride

Table of Contents

Config object defaults

Reference for the exported config object (baselineConfig): what it sets (dirs, engines, formats), why it matters, and how to override without breaking assets/head/sitemap.

Baseline setup has two parts: in your Eleventy config file, first use the config callback to add the plugin, then export your config object using Baseline’s defaults. This page covers the second part.

Baseline uses the recommended configuration shape in Eleventy’s docs.

The exported config object tells Eleventy where to look for input (src), where to write output (dist), which directories hold data and includes (_data, _includes, assets), and which template engines/formats to enable.

It’s recommended to keep Baseline’s default config object as a base because the modules are built around it. Start from it if you need to customize.

Use Baseline’s default config object

Add the plugin, then export baselineConfig so Eleventy picks up Baseline’s defaults.

import baseline, { config as baselineConfig } from '@apleasantview/eleventy-plugin-baseline';

export default async function (eleventyConfig) {
	eleventyConfig.addPlugin(baseline());
}

export const config = baselineConfig;

What the exported config sets (defaults)

export const config = {
	dir: {
		input: 'src',
		output: 'dist',
		data: '_data',
		includes: '_includes',
		assets: 'assets'
	},
	htmlTemplateEngine: 'njk',
	markdownTemplateEngine: 'njk',
	templateFormats: ['html', 'njk', 'md']
};

Why keep these as your base

These defaults match common Eleventy conventions (input: src, output: dist) and leave _data, _includes, and layouts in Eleventy’s default locations.

The assets directory is a Baseline-only convention for the assets pipeline (default: src/assets/dist/assets/).

Nunjucks is the default template engine used in Baseline’s virtual templates and is the recommended engine for templates, HTML and Markdown. Template formats to transform are explicitly set to those three formats.

Using this configuration object is not strictly required. You can configure directories however your project needs (e.g., when integrating into an existing project), and the same applies to template engines and formats. Be warned that non-default engines/formats have not been tested thoroughly at this point.

Override safely (merge from baselineConfig)

Start from Baseline’s exported config and merge your changes so shapes stay aligned:

import baseline, { config as baselineConfig } from '@apleasantview/eleventy-plugin-baseline';

/** @param {import("@11ty/eleventy").UserConfig} eleventyConfig */
export default function (eleventyConfig) {
	eleventyConfig.addPlugin(baseline());
}

export const config = {
	...baselineConfig,
	dir: {
		...baselineConfig.dir,
		// example override:
		output: 'public'
	},
	// example: add a format
	templateFormats: [...baselineConfig.templateFormats, 'liquid']
};

If you change dir.assets, update your head/asset links accordingly. Keep _includes and _data aligned with where your layouts/data live. If you add formats, ensure your templates use those engines.

Previous: Plugin entrypoint

Next: Filters