EnglishNederlandsFrançais Toggle theme

Eleventy Baseline

Start building your site, skip the recurring setup work.
Table of Contents

Plugin entrypoint

The baseline() factory is the single entry point. You call it once in your Eleventy config callback with two arguments: site settings and module options. Everything below is what that call sets up.

For the directory contract Baseline ships alongside the factory, see Config export. For the settings argument, see Site settings. This page covers the second argument, options, which controls module activation and behaviour.


Default usage

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) {
	eleventyConfig.addPlugin(baseline(settings));
}

export const config = baselineConfig;

Options

eleventyConfig.addPlugin(
	baseline(settings, {
		verbose: false,
		multilingual: false,
		sitemap: true,
		navigator: true,
		head: { titleSeparator: ' – ', showGenerator: false },
		assets: { esbuild: {} }
	})
);
  • verbose (false)
    Emit extra logging from Baseline and its modules.

  • multilingual (false)
    Turn on the multilang module. Activation is explicit: all three of options.multilingual: true, settings.defaultLanguage, and a non-empty settings.languages are required. Nothing is inferred.

  • sitemap (true)
    Generate XML sitemaps. Set to false if you produce sitemaps elsewhere.

  • navigator (true in development, false otherwise)
    Register debug globals and the optional /navigator-core.html introspection template. Boolean toggles both. Object form { template, inspectorDepth } tunes them independently: template (boolean) controls whether the page renders, inspectorDepth (integer, default 4) sets how deep the _inspect filter walks. See the navigator module for the surface.

  • head.titleSeparator (' – ')
    String placed between the page title and the site title in <title>.

  • head.showGenerator (false)
    Emit a <meta name="generator"> tag in the head.

  • assets.esbuild ({})
    An options bag forwarded to esbuild. See the esbuild documentation for keys.


What Baseline registers

In the order the entry point runs:

  • Reserved data keys - eight _* keys initialised to {} so module-namespaced data can merge cleanly. See Globals.
  • _baseline.env - name, package, version, and mode (read from process.env.ELEVENTY_ENV).
  • Date global - a date function exposed to templates.
  • HtmlBasePlugin - sets baseHref from process.env.URL or pathPrefix.
  • _baseline.features - flags reflecting the resolved options.
  • Virtual directories - synthesises the assets and public keys on eleventyConfig.directories. See Config export for the asymmetry with the on-disk static/ folder.
  • Passthrough copy - mounts the public virtual directory at the site root /.
  • _baseline.paths - resolved input, output, includes, data, assets, and public directories.
  • Drafts preprocessor - skips pages with draft: true when ELEVENTY_RUN_MODE === 'build'. Guarded: if you have already registered a drafts preprocessor, Baseline leaves it alone.
  • Runtime stores - content-map and translation-map stores; used by the page-context registry and the head module.
  • Page-context registry - per-page object built at cascade-time, exposed as _pageContext. See [[page-contex | Page context]].
  • Modules - registered in order: multilang (when active), sitemap (when active), navigator (when active), head, assets. The last two are unconditional.
  • Filters - markdownify, relatedPosts, isString. Module-specific filters are documented on Filters.
  • Shortcode: image - responsive <picture> via @11ty/eleventy-img. See Image shortcode.
  • Image dev server - on-demand image generation during --serve.

The head module's render strategy is selected by a code-level driver seam, not a user option. One driver ships today. See Internals.


Plugin metadata

baseline() returns a function whose name property is set to @apleasantview/eleventy-plugin-baseline, so eleventyConfig.hasPlugin('@apleasantview/eleventy-plugin-baseline') returns true once the plugin is added.

Not included

@11ty/eleventy-img's HTML transform (eleventyImageTransformPlugin) is not bundled. Add it yourself if you want content-level <img> rewrites. The image shortcode works either way; the difference is whether <img> tags written into Markdown also get transformed.


See also

Previous: Core reference

Next: Site settings