Eleventy Plugin Baseline

A magic carpet ride

Table of Contents

Plugin entrypoint

How to add Baseline to Eleventy, what it registers, and the options you can pass.

Baseline setup has two parts: add the plugin in your Eleventy config callback, then export the config object using Baseline's defaults. This page covers the first part. For the exported config, 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());
}

export const config = baselineConfig;

Options

Pass options to baseline():

eleventyConfig.addPlugin(
	baseline({
		verbose: false,
		enableNavigatorTemplate: false,
		enableSitemapTemplate: true
	})
);
  • verbose (false) — emit extra logging from Baseline and its modules.

  • enableNavigatorTemplate (false) — register the navigator virtual template at /navigator-core.html. Debug globals (_navigator, _context) are always available regardless. Accepts [true, depth] to set a custom inspector depth (default 2).

  • enableSitemapTemplate (true) — generate XML sitemaps. Turn off if you manage sitemaps elsewhere.

  • multilingual (false) — enable multilang-core. Requires defaultLanguage and a non-empty languages map. All three must be set for the module to load.

  • defaultLanguage (string) — IETF/BCP47 default language code (e.g. 'en'). Required when multilingual is true.

  • languages (object | string[]) — language definitions. Object { en: {}, fr: {} } or array ['en', 'fr']. Arrays are normalized to objects; invalid entries are dropped (logged if verbose: true). Required when multilingual is true.

  • assetsESBuild ({}) — options forwarded to assets-esbuild. Module defaults (minify, ES2020 target) apply inside the process function.

What Baseline registers

Everything below is registered when you add the plugin. No extra setup needed.

Registration order matters — listed here in the order they appear in the entry point:

  • multilang-core (conditional) — language collections, hreflang, i18n filters. Only when multilingual: true with valid defaultLanguage and languages.

  • HtmlBasePlugin — sets baseHref from process.env.URL or pathPrefix.

  • assets-core — asset pipeline orchestrator. Registers assets-esbuild and assets-postcss for JS/CSS processing. Adds _baseline.assets to global data.

  • head-core — enables <baseline-head> for HTML head injection via PostHTML.

  • sitemap-core — XML sitemap generation. Multilingual sites get per-language sitemaps plus an index.

  • Filtersmarkdownify, relatedPosts, isString.

  • Shortcode: image — responsive <picture> via @11ty/eleventy-img. Uses transformOnRequest for faster dev startup. See Image shortcode.

  • Image dev server — on-demand image generation during --serve via eleventyImageOnRequestDuringServePlugin.

  • Debug filters_inspect, _json, _keys — handy during template development.

  • navigator-core — debug globals (_navigator, _context) and optional virtual page. Registered last.

Globals, passthrough, drafts

  • _baseline global — a curated object with version, name, verbose, hasImageTransformPlugin. Not the full options bag. See Globals for the full shape.
  • hasImageTransformPlugin — detected via eleventyConfig.hasPlugin() before options are built. Not a user option.
  • Passthrough copy./src/static contents copied to site root /.
  • Draft preprocessor — skips draft: true pages when ELEVENTY_RUN_MODE === "build". Guarded against double-registration — if you define your own drafts preprocessor, Baseline won't overwrite it.

Plugin metadata

Sets plugin.name to @apleasantview/eleventy-plugin-baseline so eleventyConfig.hasPlugin() can detect it.

Not included

HTML image transform (eleventyImageTransformPlugin) is not bundled — add it yourself if you need content-level <img> rewrites. Baseline's image shortcode works either way.

Customize safely

Start from baselineConfig and merge if you change dirs, engines, or formats, so assets, head, and sitemap modules continue to work. See Config object defaults.