Eleventy Plugin Baseline

A magic carpet ride

Table of Contents

Plugin entrypoint

How to add Baseline to Eleventy, what it registers by default, the options you can pass, and the defaults it exports. For a code walkthrough of _baseline/eleventy.config.js, see Baseline config reference.

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 first part.

This page focuses on adding the plugin and the options it exposes. For the exported config object (dirs, engines, formats), see Config object defaults.

Default usage

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

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

// Second configuration part.
export const config = baselineConfig;

Options

  • verbose (false)
    — emit extra logging from Baseline.

  • enableNavigatorTemplate (false)
    — register the navigator template/routes; leave off unless you need the debug navigator.

  • enableSitemapTemplate (true)
    — keep sitemap generation on by default; turn off if you manage sitemaps elsewhere.

  • filterAllCollection (true)
    — override collections.all to filter out *.11tydata.js items added as a side-effect of assets-esbuild; set to false if you manage all yourself.

  • multilingual (false)
    — enable multilang core; requires defaultLanguage and a languages map.

  • defaultLanguage (string)
    — required when multilingual is true; set your default IETF code.

  • languages (object)
    — required when multilingual is true; set your language map here.

  • assetsESBuild ({ minify: true, target: "es2020" })
    — forwarded to assets-esbuild; set target/minify to match your browser support and environment.

What Baseline defaults add

  • HtmlBasePlugin
    — Sets the baseHref option to use process.env.URL or pathPrefix.

  • Assets
    — Registers assets-core for the virtual "assets" directory used internally.
    — Registers assets-postcss assets-esbuild modules; setting up the assets pipeline for PostCSS (CSS) and esbuild (JS).

  • Head
    — Registers head-core head management module; enabling the use of the PostHTML custom element <baseline-head> in templates.

  • Sitemap
    — Registers sitemap-core module with sitemap templates on by default.

  • Navigator
    — Registers navigator-core module; enabling the use of the _navigator() and _context() debug globals. /navigator-core.html virtual template is off by default.

  • Debug filters
    — Handy _inspect, _json, _keys are available for use in templates.

  • Filters
    — Adds markdownify, relatedPosts, isString filters for use in templates (may be removed in a future release).

  • Shortcode image:
    — For image processing with eleventy-img; uses transformOnRequest to process images only when requested during local development.

  • Passthrough copy
    — Copies ./src/static contents to site root / (may be changed to ./src/public in a future release).

  • Draft preprocessor
    — Skips pages with draft: true set in the front matter during ELEVENTY_RUN_MODE=build.

Not included

  • HTML image transform (@11ty/eleventy-img transform) is not bundled; add it separately if you want content-level <img> rewrites. Baseline’s image shortcode is available either way.