### Install dependencies Source: https://github.com/11ty/buildawesome/blob/main/docs/release-instructions.md Run this command to install project dependencies. ```bash npm install ``` -------------------------------- ### Eleventy serve example with serverOptions Source: https://github.com/11ty/buildawesome Example showing how to configure the dev server via `setServerOptions` in an Eleventy config. Sets port 3000, a `setup` callback that enables watch mode, and a `ready` callback that logs the server URL. Uses `runMode: "serve"` and calls `init()`, `serve()`, and `watch()`. ```javascript import Eleventy from "@11ty/eleventy"; import { defineConfig } from "@11ty/eleventy"; const elev = new Eleventy(".", "_site", { runMode: "serve", config: defineConfig((eleventyConfig) => { eleventyConfig.setServerOptions({ port: 3000, setup: async () => ({ watch: true }), ready(server) { console.log("Dev server ready at", server.url ?? "http://localhost:3000"); }, }); }), }); await elev.init(); await elev.serve(); // uses serverOptions.port await elev.watch(); ``` -------------------------------- ### serve Source: https://github.com/11ty/buildawesome Starts the server. Sets the command-line port, initializes, starts the server instance, and calls the ready callback if configured. ```APIDOC ## serve ### Description Starts the server. Sets the command-line port, initializes, starts the server instance, and calls the ready callback if configured. ### Method `async serve(port?: number): Promise` ### Parameters - **port** (number, optional) - Optional - The port to serve on. ``` -------------------------------- ### getSetupCallback Source: https://github.com/11ty/buildawesome Reads the `setup` callback from `config.serverOptions`. Returns the callback or `undefined`. ```APIDOC ## getSetupCallback ### Description Reads the `setup` callback from `config.serverOptions`. Returns the callback or `undefined`. ### Method `getSetupCallback(): Function | undefined` ``` -------------------------------- ### Install @11ty/client via npm Source: https://github.com/11ty/buildawesome/blob/main/packages/browser/README.md Install the client package from npm. Use the --save flag to add it to your project's dependencies. ```bash npm install @11ty/client --save ``` -------------------------------- ### Watch and serve usage example with error handling Source: https://github.com/11ty/buildawesome Example of initializing Eleventy in serve mode, starting the dev server on port 3000, watching, and handling SIGINT to interrupt and close gracefully. Catches errors and reports them via elev.reportError(error). ```javascript const elev = new Eleventy(".", "_site", { runMode: "serve", quietMode: true }); try { await elev.init(); await elev.serve(3000); await elev.watch(); process.on("SIGINT", async () => { elev.interrupt(); await elev.close(); process.exit(0); }); } catch (error) { elev.reportError(error); } ``` -------------------------------- ### init Source: https://github.com/11ty/buildawesome Runs the setup callback once (guarded by `_initPromise`). Merges returned options into `this.options`. Throws if options are fetched before init. ```APIDOC ## init ### Description Runs the setup callback once (guarded by `_initPromise`). Merges returned options into `this.options`. Throws if options are fetched before init. ### Method `async init(): Promise` ``` -------------------------------- ### Install Build Awesome with npm Source: https://github.com/11ty/buildawesome/blob/main/README.md Install the package as a dev dependency. The second command installs the backwards-compatible @11ty/eleventy package. ```bash npm install @awesome.me/buildawesome --save-dev # Backwards compatible here too: npm install @11ty/eleventy --save-dev ``` -------------------------------- ### sendBuildStart Source: https://github.com/11ty/buildawesome Forwards a build start notification to the server if it implements the method. ```APIDOC ## sendBuildStart ### Description Forwards a build start notification to the server if it implements the method. ### Method `async sendBuildStart(): Promise` ``` -------------------------------- ### Eleventy constructor example with options Source: https://github.com/11ty/buildawesome Creates an Eleventy instance with input directory 'content', output 'dist', watch mode, ESM loader, and a config callback that adds a watch target for SCSS files. ```javascript import Eleventy from "@11ty/eleventy"; const elev = new Eleventy({ input: "content", output: "dist", runMode: "watch", loader: "esm", config: (eleventyConfig) => eleventyConfig.addWatchTarget("src/scss/**/*.scss"), }); ``` -------------------------------- ### toJSON() usage example Source: https://github.com/11ty/buildawesome Example of using toJSON() to render templates and iterate over results, logging url, inputPath, and content length for each entry. ```javascript const elev = new Eleventy({ input: "src", runMode: "build" }); const results = await elev.toJSON(); for (const entry of results) { console.log(entry.url, entry.inputPath, entry.content.length); } ``` -------------------------------- ### defineConfig with passthrough copy, filter, plugin, and event Source: https://github.com/11ty/buildawesome Example configuration for an Eleventy project using the defineConfig helper. It adds a passthrough copy for the assets directory, a year filter, a plugin with the immediate option set to false, and listens for the buildawesome.before event to log the run mode. ```javascript import { defineConfig } from "@11ty/eleventy"; export default defineConfig((eleventyConfig) => { eleventyConfig.addPassthroughCopy("assets"); eleventyConfig.addFilter("year", (date) => date.getFullYear()); eleventyConfig.addPlugin(require("./my-plugin.js"), { immediate: false }); eleventyConfig.on("buildawesome.before", (args) => { console.log("building in", args.runMode, "mode"); }); }); ``` -------------------------------- ### Watch / serve orchestration method signatures Source: https://github.com/11ty/buildawesome Methods for watch and serve orchestration. serve(port) starts the dev server (port may also come from config serverOptions.port). watch() performs an initial build, then watches and rebuilds; honours isRunInitialBuild. getWatchedTargets() returns resolved watch targets and ignore globs. close() closes chokidar + dev server; stopWatch() is a renamed alias of close(); interrupt() drains watch queue on SIGINT. ```typescript async watch(): Promise; async serve(port?: number): Promise; async startWatch(): Promise; async getWatchedTargets(): Promise<{ targets: string[]; ignores: string[] }>; async close(): Promise; // closes chokidar + dev server async stopWatch(): Promise; // renamed alias of close() interrupt(): void; // SIGINT: drain watch queue async triggerWatchRunForPath(path: string): Promise; ``` -------------------------------- ### watchPassthroughCopy Source: https://github.com/11ty/buildawesome Adds globs to watch targets and to the running chokidar instance if started. ```APIDOC ## watchPassthroughCopy ### Description Adds globs to watch targets and to the running chokidar instance if started. ### Method `watchPassthroughCopy(globs: string[]): void` ### Parameters - **globs** (string[]) - Required - Array of glob patterns to watch. ``` -------------------------------- ### Eleventy HTML Transformer Integration Example Source: https://github.com/11ty/buildawesome Shows how to configure the Eleventy HTML transformer in an Eleventy config file. It rewrites absolute hrefs, conditionally lowercases URLs per page, and removes the built-in input-path transform for the 'html' extension. The example uses `addUrlTransform` with priority and enabled options, and `remove` to filter by entry name. ```javascript import { defineConfig } from "@11ty/eleventy"; export default defineConfig((eleventyConfig) => { const transformer = eleventyConfig.htmlTransformer; // Rewrite every absolute href in HTML output transformer.addUrlTransform( "html", function (url, { attribute, tag }) { if (attribute === "href" && url.startsWith("/")) { return `/app${url}`; } return url; }, { priority: 10, name: "my-prefix-rewrite" }, ); // Opt out per-page via context transformer.addUrlTransform( "html", function (url) { return url.toLowerCase(); }, { enabled: (context) => context.page?.url !== "/skip/", }, ); // Remove the built-in input-path transform for a single extension transformer.remove("html", (entry) => entry.name === "@11ty/posthtml-urls"); }); ``` -------------------------------- ### Import and register I18nPlugin with options Source: https://github.com/11ty/buildawesome Example of importing and registering the I18nPlugin with defaultLanguage 'en' and errorMode 'allow-fallback'. The comment shows usage of the locale_url filter in templates. ```javascript import { I18nPlugin } from "@11ty/eleventy"; export default function (eleventyConfig) { eleventyConfig.addPlugin(I18nPlugin, { defaultLanguage: "en", errorMode: "allow-fallback", }); } // In templates: … ``` -------------------------------- ### TemplateEngineManager methods Source: https://github.com/11ty/buildawesome Resolves a template format to its engine instance. Provides methods to check engine existence, get engine classes, and retrieve engine instances. ```APIDOC ## `TemplateEngineManager` methods ### Description Resolves a template format to its engine instance. Provides methods to check engine existence, get engine classes, and retrieve engine instances. ### Methods #### `getConfig()` Getter for the merged config. #### `hasEngine(name)` Returns whether a format key resolves to an engine. #### `getClassNameFromTemplateKey(key)` Returns the engine class name for a format. #### `async getEngineClassByExtension(extension)` Resolves the engine class for a file extension. #### `async getCustomEngineClass()` Resolves a custom engine class (loaded via `import` when the key is not built-in). #### `isEngineRemovedFromCore(name)` Flags formats removed from core. #### `async getEngine(name, extensionMap?) : Promise` The public resolver (async — engines may need async init). #### `reset()` Clears cached engines. ### Default Format Mapping - `"liquid"`/`"md"` → `Liquid` - `"njk"` → `Nunjucks` - `"html"` → `Html` - `"11ty.js"`/`"11ty.cjs"`/`"11ty.mjs"`/`"11ty.ts"`/`"11ty.cts"`/`"11ty.mts"` → `JavaScript` - anything else → `CustomEngine` (an `addExtension` entry must exist). ``` -------------------------------- ### Import and register RenderPlugin with accessGlobalData Source: https://github.com/11ty/buildawesome Imports RenderPlugin from the package root and registers it with accessGlobalData: true, which exposes the parent template data cascade to the rendered shortcode. The comment shows a Liquid usage example: {% renderTemplate "md" %}# Hi{% endrenderTemplate %}. ```javascript import { RenderPlugin } from "@11ty/eleventy"; export default function (eleventyConfig) { eleventyConfig.addPlugin(RenderPlugin, { accessGlobalData: true, }); } // In Liquid: {% renderTemplate "md" %}# Hi{% endrenderTemplate %} ``` -------------------------------- ### Using engine instances from configuration Source: https://github.com/11ty/buildawesome Shows how to override or amend library instances and set Liquid options from an Eleventy configuration file. ```APIDOC ## Using engine instances from configuration ### Description Shows how to override or amend library instances and set Liquid options from an Eleventy configuration file. ### Example ```js import { defineConfig } from "@11ty/eleventy"; export default defineConfig((eleventyConfig) => { // Override a library instance entirely eleventyConfig.setLibrary("md", require("markdown-it")({ html: true })); // Amend whichever instance is active (override or default) eleventyConfig.amendLibrary("md", (mdLib) => { mdLib.set({ linkify: true }); }); // Liquid package options eleventyConfig.setLiquidOptions({ jsTruthy: false, strictFilters: false }); }); ``` ``` -------------------------------- ### Run ava tests Source: https://github.com/11ty/buildawesome/blob/main/docs/release-instructions.md Run this command to execute the ava test suite. ```bash npm run test ``` -------------------------------- ### initServerInstance Source: https://github.com/11ty/buildawesome Initializes the server instance. For the default module, sets up a watcher over watch targets and creates the server via `getServer`. ```APIDOC ## initServerInstance ### Description Initializes the server instance. For the default module, sets up a watcher over watch targets and creates the server via `getServer`. ### Method `async initServerInstance(): Promise` ``` -------------------------------- ### Run eslint check Source: https://github.com/11ty/buildawesome/blob/main/docs/release-instructions.md Run this command to execute the eslint check. ```bash npm run check ``` -------------------------------- ### getCreatedTimestamp Source: https://github.com/11ty/buildawesome Runs git log to get the creation timestamp of a file. Returns the timestamp in milliseconds or undefined on failure. ```APIDOC ## getCreatedTimestamp ### Description Runs git log to get the creation timestamp of a file. Returns the timestamp in milliseconds or undefined on failure. ### Method getCreatedTimestamp ### Endpoint getCreatedTimestamp(filePath) ### Parameters #### Path Parameters - **filePath** (string) - Required - The file path to query. ### Response #### Success Response (Promise) - Returns the creation timestamp in milliseconds, or undefined on failure. ``` -------------------------------- ### Using Engine Instances from Configuration Source: https://github.com/11ty/buildawesome Shows how to override or amend library instances and set Liquid options via the Eleventy config. `setLibrary` replaces the entire library instance, `amendLibrary` modifies the active instance, and `setLiquidOptions` sets Liquid package options. ```javascript import { defineConfig } from "@11ty/eleventy"; export default defineConfig((eleventyConfig) => { // Override a library instance entirely eleventyConfig.setLibrary("md", require("markdown-it")({ html: true })); // Amend whichever instance is active (override or default) eleventyConfig.amendLibrary("md", (mdLib) => { mdLib.set({ linkify: true }); }); // Liquid package options eleventyConfig.setLiquidOptions({ jsTruthy: false, strictFilters: false }); }); ``` -------------------------------- ### getUpdatedTimestamp Source: https://github.com/11ty/buildawesome Runs git log to get the last update timestamp of a file. Returns the timestamp in milliseconds or undefined on failure. ```APIDOC ## getUpdatedTimestamp ### Description Runs git log to get the last update timestamp of a file. Returns the timestamp in milliseconds or undefined on failure. ### Method getUpdatedTimestamp ### Endpoint getUpdatedTimestamp(filePath) ### Parameters #### Path Parameters - **filePath** (string) - Required - The file path to query. ### Response #### Success Response (Promise) - Returns the last update timestamp in milliseconds, or undefined on failure. ``` -------------------------------- ### Run test coverage Source: https://github.com/11ty/buildawesome/blob/main/docs/release-instructions.md Run this command to generate test coverage reports. ```bash npm run coverage ``` -------------------------------- ### Run tests with npm test Source: https://github.com/11ty/buildawesome/blob/main/README.md Runs the project's test suites, including ava, Node.js Test runner, Vitest (Browser Mode), and benchmarks. ```bash npm test ``` -------------------------------- ### elev.init() Source: https://github.com/11ty/buildawesome Initializes the Eleventy instance, loading configuration and preparing the build. Must be called before write(). ```APIDOC ## init() ### Description Initializes the Eleventy instance, loading configuration and preparing the build. Must be called before write(). ### Method init ### Request Example ```js await elev.init(); ``` ``` -------------------------------- ### Get updated git timestamp with getUpdatedTimestamp Source: https://github.com/11ty/buildawesome Imports getUpdatedTimestamp from @11ty/eleventy/utils/git and awaits it with a file path. Logs the ISO timestamp if the file is in git, otherwise logs 'not in git'. ```javascript import { getUpdatedTimestamp } from "@11ty/eleventy/utils/git"; const ts = await getUpdatedTimestamp("./pages/about.md"); console.log(ts ? new Date(ts).toISOString() : "not in git"); ``` -------------------------------- ### Core.getHelp() Source: https://github.com/11ty/buildawesome Returns the full CLI help text, including usage and all supported arguments. This is a static method on the Core class. ```APIDOC ## Core.getHelp() ### Description Returns the full CLI help text (usage, arguments `--version`, `--input`, `--output`, `--serve`, `--port`, `--watch`, `--incremental`, `--ignore-initial`, `--formats`, `--quiet`, `--config`, `--pathprefix`, `--dryrun`, `--loader`, `--to`, `--events-file`, `--help`). ### Method `static getHelp(): string;` ### Returns - **string** - The full CLI help text. ``` -------------------------------- ### init(options?) Source: https://github.com/11ty/buildawesome Initializes configuration, engines, extension map, template data, and a TemplateWriter. Emits several events and should be called once before write() or toJSON(), though those methods call it lazily if needed. ```APIDOC ## init(options?) ### Description Initializes configuration, engines, extension map, template data, and a `TemplateWriter`. Emits `buildawesome.config`, `buildawesome.env`, `buildawesome.extensionmap`, `buildawesome.directories`. Call once before `write()`/`toJSON()` (they call it lazily if needed). When `viaConfigReset` is true, config event listeners are reset rather than re-initialized. ### Method init ### Signature ```js async init(options?: { viaConfigReset?: boolean }): Promise ``` ### Parameters #### Options - **viaConfigReset** (boolean) - Optional - If true, config event listeners are reset rather than re-initialized. ``` -------------------------------- ### initializeConfig(initOverrides?) Source: https://github.com/11ty/buildawesome Creates or reuses the TemplateConfig, applies run-mode/logger/directories/template-formats, sets pathPrefix, runs the config callback, computes env, and initializes environment variables. ```APIDOC ## initializeConfig(initOverrides?) ### Description Creates or reuses the `TemplateConfig`, applies run-mode/logger/directories/template-formats, sets `pathPrefix`, runs `options.config` (the `CoreOptions.config` callback), computes `env` (`{ source, runMode, config, root }`), initializes environment variables, then `eleventyConfig.init()` merges the user config file with defaults. ### Method initializeConfig ### Signature ```js async initializeConfig(initOverrides?): Promise ``` ### Parameters #### Options - **initOverrides** (object) - Optional - Overrides for initialization. ### Notes Project config file discovery order (`src/TemplateConfig.js`): `buildawesome.config.{js,mjs,cjs,ts,...}`, `.eleventy.js`, `eleventy.config.{js,mjs,cjs,ts,...}`. ``` -------------------------------- ### Audit production dependencies Source: https://github.com/11ty/buildawesome/blob/main/docs/release-instructions.md Run this command to audit production dependencies, excluding dev dependencies. ```bash npm audit --omit=dev ``` -------------------------------- ### Check outdated dependencies with npm Source: https://github.com/11ty/buildawesome/blob/main/docs/release-instructions.md Alternative command to check for outdated dependencies. Use 'npm update --save' to update them. ```bash npm outdated ``` ```bash npm update --save ``` -------------------------------- ### write(subtype?) Source: https://github.com/11ty/buildawesome Builds the site to the file system. Normalizes the subtype to 'fs:' and calls executeBuild, returning the passthrough copy and template results. ```APIDOC ## write(subtype?) ### Description Builds to the file system. Normalizes `subtype` to `fs:` (`fs:templates` skips passthrough copy, `fs:copy` skips templates) and calls `executeBuild`. Returns `[passthroughCopy, templates]` arrays in `fs` mode, or just `templates` in `fs:...` mode. ### Method write ### Signature ```js async write(subtype?: string): Promise<[passthroughCopyResults, templateResults]> ``` ### Parameters #### Options - **subtype** (string) - Optional - Subtype to control build behavior (e.g., 'templates' or 'copy'). ``` -------------------------------- ### initializeConfig(initOverrides?) method signature Source: https://github.com/11ty/buildawesome Creates or reuses the TemplateConfig, applies run-mode/logger/directories/template-formats, sets pathPrefix, runs options.config (the CoreOptions.config callback), computes env ({ source, runMode, config, root }), initializes environment variables, then eleventyConfig.init() merges the user config file with defaults. Project config file discovery order (src/TemplateConfig.js): buildawesome.config.{js,mjs,cjs,ts,...}, .eleventy.js, eleventy.config.{js,mjs,cjs,ts,...}. ```typescript async initializeConfig(initOverrides?): Promise; ``` -------------------------------- ### init(options?) method signature Source: https://github.com/11ty/buildawesome Initializes configuration, engines, extension map, template data, and a TemplateWriter. Emits buildawesome.config, buildawesome.env, buildawesome.extensionmap, buildawesome.directories. Call once before write()/toJSON(); they call it lazily if needed. When viaConfigReset is true, config event listeners are reset rather than re-initialized. ```typescript async init(options?: { viaConfigReset?: boolean }): Promise ``` -------------------------------- ### setServerOptions(options?, override?) Source: https://github.com/11ty/buildawesome Configures the development server options for Eleventy's serve mode. Accepts an options object and an optional override flag, and returns void. ```APIDOC ## setServerOptions(options?, override?) ### Description Configures the development server options for Eleventy's serve mode. Accepts an options object and an optional override flag, and returns void. ### Method setServerOptions ### Signature setServerOptions(options?: object, override?: boolean = false): void; ### Parameters #### Options Object - **module** (string) - Optional - npm module name (must resolve inside the project `node_modules`). Default: `"@11ty/eleventy-dev-server"` - **port** (number) - Optional - Server port (CLI `--port` wins). Default: `8080` - **pathPrefix** (string) - Optional - URL prefix for served output. Default: normalized `config.pathPrefix` - **setup** (Function) - Optional - Async callback whose return value merges into server options before the server is created - **ready** (Function) - Optional - Called with the server instance after startup - **logger** ({ log, info, warn, error }) - Optional - Server log destination. Default: forced-output logger #### Override Parameter - **override** (boolean) - Optional - Whether to override existing options. Default: `false` ### Return Value void ### Example ```js import Eleventy from "@11ty/eleventy"; import { defineConfig } from "@11ty/eleventy"; const elev = new Eleventy(".", "_site", { runMode: "serve", config: defineConfig((eleventyConfig) => { eleventyConfig.setServerOptions({ port: 3000, setup: async () => ({ watch: true }), ready(server) { console.log("Dev server ready at", server.url ?? "http://localhost:3000"); }, }); }), }); await elev.init(); await elev.serve(); // uses serverOptions.port await elev.watch(); ``` ``` -------------------------------- ### Default server options Source: https://github.com/11ty/buildawesome Default options for the dev server wrapper, including module, port, and commented-out optional settings. ```javascript const DEFAULT_SERVER_OPTIONS = { module: "@11ty/eleventy-dev-server", port: 8080, // pathPrefix: "/", // setup: function() {}, // ready: function(server) {}, // logger: { log, info, error } }; ``` -------------------------------- ### elev.write() Source: https://github.com/11ty/buildawesome Executes the build and writes output files. Returns an array containing the passthrough copy and template results. ```APIDOC ## write() ### Description Executes the build and writes output files. Returns an array containing the passthrough copy and template results. ### Method write ### Response Example ```js const [passthroughCopy, templates] = await elev.write(); ``` ``` -------------------------------- ### getDevServer (static) Source: https://github.com/11ty/buildawesome Lazily imports the `@11ty/eleventy-dev-server` module. Returns a promise that resolves to the module. ```APIDOC ## getDevServer (static) ### Description Lazily imports the `@11ty/eleventy-dev-server` module. Returns a promise that resolves to the module. ### Method `static getDevServer(): Promise` ``` -------------------------------- ### Final options assembly Source: https://github.com/11ty/buildawesome Assembles final options by merging pathPrefix, logger, defaults, and user-provided server options. ```javascript this.#options = Object.assign( { pathPrefix: PathPrefixer.normalizePathPrefix(this.config.pathPrefix), logger: this.getForcedOutputLogger(), }, DEFAULT_SERVER_OPTIONS, this.config.serverOptions, // from eleventyConfig.setServerOptions(...) ); ``` -------------------------------- ### restart Source: https://github.com/11ty/buildawesome Restarts the server. Clears options, closes the current server, and re-serves with the saved CLI port. ```APIDOC ## restart ### Description Restarts the server. Clears options, closes the current server, and re-serves with the saved CLI port. ### Method `async restart(): Promise` ``` -------------------------------- ### setOutputDir Source: https://github.com/11ty/buildawesome Sets the output directory for the server. This value is applied when the server initializes. ```APIDOC ## setOutputDir ### Description Sets the output directory for the server. This value is applied when the server initializes. ### Method `setOutputDir(outputDir: string): void` ### Parameters - **outputDir** (string) - Required - The output directory path. ``` -------------------------------- ### getServerModule Source: https://github.com/11ty/buildawesome Resolves the server module by name. Defaults to the dev server; otherwise resolves a local `node_modules` peer dependency with path containment enforcement. Throws errors for invalid names, missing `main`, or missing static `getServer`. Checks compatibility and falls back to default on error. ```APIDOC ## getServerModule ### Description Resolves the server module by name. Defaults to the dev server; otherwise resolves a local `node_modules` peer dependency with path containment enforcement. Throws errors for invalid names, missing `main`, or missing static `getServer`. Checks compatibility and falls back to default on error. ### Method `async getServerModule(name: string): Promise` ### Parameters - **name** (string) - Required - The server module name. ``` -------------------------------- ### Userspace directories getters Source: https://github.com/11ty/buildawesome Object returned by the `buildawesome.directories` event and `eleventyConfig.directories`. Provides five `string` getters: `input`, `data`, `includes`, `layouts`, and `output`. The `ProjectDirectories.getUserspaceInstance()` method returns a read-only projection with these getters. ```javascript { input, data, includes, layouts, output } // getters on the userspace instance ``` -------------------------------- ### executeBuild(to?) Source: https://github.com/11ty/buildawesome Runs the build pipeline and emits buildawesome.before/after events. Throws an error for invalid arguments and handles errors based on the source. ```APIDOC ## executeBuild(to?) ### Description Runs the pipeline and emits `buildawesome.before` / `buildawesome.after` / `buildawesome.aftererror`. On failure it calls `errorHandler.once("error" | "fatal", ...)` — the severity depends on `this.source` (`script` → `error`, otherwise `fatal` — `fatal` sets `process.exitCode = 1`). ### Method executeBuild ### Signature ```js async executeBuild(to?: "fs" | "fs:templates" | "json"): Promise ``` ### Parameters #### Options - **to** (string) - Optional - Must be one of "fs", "fs:templates", or "json". Throws `Error("Invalid argument for \`Eleventy->executeBuild(...)\`, expected \"json\", \"fs\", or \"fs:templates\".")` for other values. ``` -------------------------------- ### Watch / serve orchestration Source: https://github.com/11ty/buildawesome Methods for watching files, serving the site, and managing the watch process. Includes watch(), serve(), startWatch(), getWatchedTargets(), close(), stopWatch(), interrupt(), and triggerWatchRunForPath(). ```APIDOC ## Watch / serve orchestration ### Description Methods for watching files, serving the site, and managing the watch process. `serve(port)` starts the dev server (the port may also come from config `serverOptions.port`). `watch()` performs an initial build, then watches and rebuilds; it honours `isRunInitialBuild`. `getWatchedTargets()` returns the resolved watch targets and ignore globs. ### Methods - `async watch(): Promise` - `async serve(port?: number): Promise` - `async startWatch(): Promise` - `async getWatchedTargets(): Promise<{ targets: string[]; ignores: string[] }>` - `async close(): Promise` — closes chokidar + dev server - `async stopWatch(): Promise` — renamed alias of close() - `interrupt(): void` — SIGINT: drain watch queue - `async triggerWatchRunForPath(path: string): Promise` ### Example ```js const elev = new Eleventy(".", "_site", { runMode: "serve", quietMode: true }); try { await elev.init(); await elev.serve(3000); await elev.watch(); process.on("SIGINT", async () => { elev.interrupt(); await elev.close(); process.exit(0); }); } catch (error) { elev.reportError(error); } ``` ``` -------------------------------- ### initWatch() (removed) Source: https://github.com/11ty/buildawesome Removed method that throws an Error directing to use startWatch() instead. ```APIDOC ## initWatch() ### Description Removed in v4. Throws Error("#initWatch() was removed in v4. Use #startWatch() instead..."). ``` -------------------------------- ### Catching Eleventy build errors with try/catch Source: https://github.com/11ty/buildawesome Shows how to catch errors from elev.write() after init(). Errors are re-thrown after write()/toJSON(). BaseError subclasses carry .originalError / .cause and often .filePath. Checks for DuplicatePermalinkOutputError by name and falls back to filePath. ```javascript import Eleventy from "@11ty/eleventy"; const elev = new Eleventy({ input: "." }); try { await elev.init(); const results = await elev.write(); } catch (error) { // BaseError subclasses carry .originalError / .cause and often .filePath if (error.name === "DuplicatePermalinkOutputError") { console.error("Permalink conflict:", error.message); } else if (error.filePath) { console.error("File:", error.filePath, "->", error.message); } } ``` -------------------------------- ### ProjectDirectories Source: https://github.com/11ty/buildawesome Resolves the four user-facing directories (input, data, includes, layouts, output) for an Eleventy project. Provides setters, getters, and helper methods to manage and query these directories. ```APIDOC ## ProjectDirectories ### Description Resolves the four user-facing directories (input, data, includes, layouts, output) for an Eleventy project. Provides setters, getters, and helper methods to manage and query these directories. ### Methods #### Setters - `setInput(dirOrFile, inputDir = undefined)` - Sets the input directory or file. - `setIncludes(dir)` - Sets the includes directory. - `setLayouts(dir)` - Sets the layouts directory. - `setData(dir)` - Sets the data directory. - `setOutput(dir)` - Sets the output directory. - `setViaConfigObject(configDirs = {})` - Sets directories via a configuration object. - `freeze()` - Locks CLI-provided values. #### Getters - `input` - Returns the input directory. - `data` - Returns the data directory. - `includes` - Returns the includes directory. - `layouts` - Returns the layouts directory. - `output` - Returns the output directory. #### Helpers - `isTemplateFile(filePath)` - Checks if a file path is a template file. - `getInputPath(filePathRelativeToInputDir)` - Gets the input path from a relative path. - `getInputPathRelativeToInputDirectory(...)` - Gets the input path relative to the input directory. - `getOutputPathRelativeToOutputDirectory(...)` - Gets the output path relative to the output directory. - `getLayoutPath(...)` - Gets the layout path. - `getLayoutPathRelativeToInputDirectory(...)` - Gets the layout path relative to the input directory. - `getProjectPath(filePath)` - Gets the project path. - `isFileInProjectFolder(filePath)` - Checks if a file is in the project folder. - `isFileInOutputFolder(filePath)` - Checks if a file is in the output folder. - `getUserspaceInstance()` - Returns a read-only projection. - `toString()` - Returns a string representation. - `updateInputDependencies()` - Updates input dependencies. - `normalizeDirectoryPathRelativeToInputDirectory(filePath)` - Normalizes a directory path relative to the input directory. ### Defaults - input: `.` - includes: `_includes` - data: `_data` - output: `_site` ``` -------------------------------- ### Html constructor Source: https://github.com/11ty/buildawesome Creates an Html engine instance. The engine is cacheable and its compile method returns a function that returns the input string unchanged, as HTML passes through the pipeline without modification. ```APIDOC ## `Html` constructor ### Description Creates an Html engine instance. The engine is cacheable and its compile method returns a function that returns the input string unchanged, as HTML passes through the pipeline without modification. ### Method constructor ### Endpoint `new Html(name: string, eleventyConfig: TemplateConfig)` ### Parameters #### Constructor Parameters - **name** (string) - Required - The template format name. - **eleventyConfig** (TemplateConfig) - Required - The Eleventy configuration object. ### Properties - **cacheable** (getter) - Returns `true`. ### Methods - **async compile(str)** - Returns `function () { return str; }`, i.e. HTML passes through unchanged (preprocessing engines in the pipeline run before it; see `TemplateRender` in [template-objects.md](template-objects.md)). ``` -------------------------------- ### buildawesome.before/after arguments Source: https://github.com/11ty/buildawesome Arguments object passed to the `buildawesome.before` and `buildawesome.after` events. Contains `directories` (userspace projection), `inputDir` (backwards compat), `dir` (deprecated config.dir), `runMode`, `outputMode`, `dryRun`, `incremental`, and after-only fields `results` and `uses`. ```javascript { directories, // userspace projection inputDir, // backwards compat dir, // deprecated config.dir runMode, outputMode, // "fs" | "json" | ... dryRun, incremental, // booleans results, // after only: template results uses, // after only: dependency graph map } ``` -------------------------------- ### new Eleventy(options) Source: https://github.com/11ty/buildawesome Creates a new Eleventy build instance. Accepts an options object or positional arguments (input, output, options, templateConfig). ```APIDOC ## Constructor ### Description Creates a new Eleventy build instance. Accepts an options object or positional arguments (input, output, options, templateConfig). ### Signature ```js constructor(options?: CoreOptions, templateConfig?: any); constructor(input?: string, output?: string, options?: Omit, templateConfig?: any); ``` ### Parameters #### Options (CoreOptions) - **input** (string) - Optional - Directory or filename for input files (e.g. `.` or `index.md`) - **output** (string) - Optional - Default: `_site` - Directory for output files - **source** ("cli" | "script") - Optional - Default: `"script"` - Whether invoked from the CLI (`cli`) or programmatically (`script`); changes fatal/error severity handling - **runMode** ("build" | "serve" | "watch") - Optional - Default: `"build"` - Build mode - **dryRun** (boolean) - Optional - Default: `false` - Don't write files - **configPath** (string) - Optional - Override the project config file path - **pathPrefix** (string) - Optional - Default: `"/"` - URL prefix applied by `url` filters - **quietMode** (boolean) - Optional - Default: `false` - Suppress non-error output - **inputDir** (string) - Optional - Explicit input directory (used with a file `input`) - **loader** ("esm" | "cjs" | "auto") - Optional - Default: `"auto"` - Module loader mode for config/data/template files - **config** (ConfigurationApi) - Optional - A `(eleventyConfig) => unknown` callback run before the default config #### Positional Arguments - **input** (string) - Optional - Directory or filename for input files - **output** (string) - Optional - Directory for output files - **options** (Omit) - Optional - Additional options - **templateConfig** (any) - Optional - An existing `TemplateConfig` instance ### Request Example ```js import Eleventy from "@11ty/eleventy"; const elev = new Eleventy({ input: "./src", output: "./public", pathPrefix: "/docs/", dryRun: true, }); ``` ```js import Eleventy, { defineConfig } from "@11ty/eleventy"; const elev = new Eleventy(".", "_site", { config: defineConfig((eleventyConfig) => { eleventyConfig.addPassthroughCopy("images"); eleventyConfig.addFilter("shout", (s) => `${s}`.toUpperCase()); }), }); ``` ``` -------------------------------- ### hasOptionsChanged Source: https://github.com/11ty/buildawesome Compares the current `config.serverOptions` against the saved options to detect changes. ```APIDOC ## hasOptionsChanged ### Description Compares the current `config.serverOptions` against the saved options to detect changes. ### Method `hasOptionsChanged(): boolean` ``` -------------------------------- ### Serve constructor Source: https://github.com/11ty/buildawesome Constructor for the Serve class, requiring no arguments. ```javascript constructor() // no required arguments ``` -------------------------------- ### Benchmark class skeleton Source: https://github.com/11ty/buildawesome Constructor initializes timeSpent, timesCalled, and beforeTimers. Methods reset, getNewTimestamp, before, after, incrementCount, getTimesCalled, and getTotal are available. ```javascript export default class Benchmark { constructor() // timeSpent = 0, timesCalled = 0, beforeTimers = [] } ``` -------------------------------- ### Instantiate Eleventy with an options object Source: https://github.com/11ty/buildawesome Creates a new Eleventy instance using an object with input, output, pathPrefix, and dryRun. The dryRun option prevents writing files. ```javascript import Eleventy from "@11ty/eleventy"; const elev = new Eleventy({ input: "./src", output: "./public", pathPrefix: "/docs/", dryRun: true, }); ``` -------------------------------- ### Update minor dependencies in package.json Source: https://github.com/11ty/buildawesome/blob/main/docs/release-instructions.md Run this command to update minor dependencies in package.json. It targets the 'prod' dependency group and uses the 'minor' update level. ```bash npx npm-check-updates --target minor -u --dep prod ``` -------------------------------- ### setServerOptions(options?, override?) Source: https://github.com/11ty/buildawesome Sets server options. Deep-merges unless `override` is true. ```APIDOC ## setServerOptions(options?, override?) ### Description Sets server options. Deep-merges unless `override` is true. ### Method setServerOptions ### Parameters - **options** (object) - Optional - Server options. - **override** (boolean) - Optional - Default `false`. If true, replaces existing options instead of merging. ### Returns void ``` -------------------------------- ### addAsyncShortcode(name: string, callback: Function): void Source: https://github.com/11ty/buildawesome Registers an asynchronous shortcode. ```APIDOC ## addAsyncShortcode(name: string, callback: Function): void ### Description Registers an asynchronous shortcode. ### Method addAsyncShortcode ### Parameters - **name** (string) - Required - The name of the shortcode. - **callback** (Function) - Required - The async shortcode function. ### Response No return value. ``` -------------------------------- ### applyBaseToUrl Source: https://github.com/11ty/buildawesome Named export that applies a base URL to a given URL. Throws an Error when the URL is false, such as when linking to a page with `permalink: false`. ```APIDOC ## applyBaseToUrl ### Description Named export that applies a base URL to a given URL. Throws an Error when the URL is false, such as when linking to a page with `permalink: false`. ### Method Function ### Signature ```js applyBaseToUrl(url: string, base: string) ``` ### Parameters - **url** (string) - Required - The URL to transform. - **base** (string) - Required - The base URL or path prefix to apply. ### Throws - `Error` when the URL is `false` (e.g. linking to a `permalink: false` page). ``` -------------------------------- ### resetConfig Source: https://github.com/11ty/buildawesome Clears watch targets, used on config reset. ```APIDOC ## resetConfig ### Description Clears watch targets, used on config reset. ### Method `resetConfig(): void` ``` -------------------------------- ### getShortcodes(options?) Source: https://github.com/11ty/buildawesome Retrieves all shortcodes. ```APIDOC ## getShortcodes(options?) ### Description Retrieves all shortcodes. ### Method getShortcodes ### Parameters - **options** (object) - Optional - Additional options. ### Response Returns an array of shortcodes. ``` -------------------------------- ### ExtensionMap Source: https://github.com/11ty/buildawesome Maps template formats to engines and globs. It is created in `CoreMinimal.init()` and emitted to plugins via the `buildawesome.extensionmap` event. ```APIDOC ## ExtensionMap ### Description Maps template formats to engines and globs. It is created in `CoreMinimal.init()` and emitted to plugins via the `buildawesome.extensionmap` event. ### Constructor `constructor(config: TemplateConfig)` ### Members #### `setFormats(formatKeys: string[] = [])` Splits into `validTemplateLanguageKeys` (known extensions) and `passthroughCopyKeys` (unknown → passthrough). #### `setTemplateConfig` / `get config` Throws `Error("Internal error: Missing or invalid \`config\` argument.")` for non-`TemplateConfig`. #### `engineManager` Getter/setter; getter throws before set. #### `reset()` Resets `engineManager`. #### `getFileList(path, dir)` Returns files by extension. #### `isFullTemplateFilePath(path)` #### `getCustomExtensionEntry(extension)` #### `getValidExtensionsForPath(path)` #### `shouldSpiderJavaScriptDependencies(path)` `async` #### `getPassthroughCopyGlobs(inputDir)` / `getValidGlobs(inputDir)` / `getGlobs(inputDir)` / `_getGlobs(formatKeys, inputDir)` Glob generation for `Files`/`eleventyFiles`. #### `hasExtension(key)` / `hasEngine(pathOrKey)` #### `getExtensionsFromKey(key)` / `getExtensionEntriesFromKey(key)` Engine lookup (used by `TemplateEngine.extensions`). #### `getKey(pathOrKey)` / `getExtensionEntry(pathOrKey)` / `getExtensionEntryFromPath` (via `#getValidTemplateExtensions`) Resolution. #### `removeTemplateExtension(path)` Strips the template extension. #### `extensionToKeyMap` (getter) Extension → engine key map. #### `getReadableFileExtensions()` ``` -------------------------------- ### setOutputDirectory(dir) Source: https://github.com/11ty/buildawesome Sets the output directory. Throws an Error during plugin execution. ```APIDOC ## setOutputDirectory(dir) ### Description Sets the output directory. Throws an Error during plugin execution. ### Method setOutputDirectory ### Parameters - **dir** (string) - Required - The output directory path. ### Returns void ### Errors - Throws `Error("The \`set*Directory\` configuration API methods are not yet allowed in plugins.")` during plugin execution. ``` -------------------------------- ### addMarkdownHighlighter(highlightFn: Function): void Source: https://github.com/11ty/buildawesome Sets the markdown highlighter function used by syntax highlighting plugins. ```APIDOC ## addMarkdownHighlighter(highlightFn: Function): void ### Description Sets the markdown highlighter function used by syntax highlighting plugins. ### Method addMarkdownHighlighter ### Parameters - **highlightFn** (Function) - Required - The highlight function. ### Response No return value. ``` -------------------------------- ### EleventyServerless Source: https://github.com/11ty/buildawesome Alias of `EleventyServerlessBundlerPlugin`; also removed and throws the same error. ```APIDOC ## EleventyServerless ### Description Alias of `EleventyServerlessBundlerPlugin`. This plugin has been removed from core v3.0 and throws the same error when called. ### Method N/A (JavaScript function) ### Endpoint N/A ### Parameters #### Function Parameters - **eleventyConfig** (UserConfig) - Required - The Eleventy configuration object. - **options** (object) - Optional - Configuration options. ### Response #### Error Response - Throws `Error("Following feedback from our Community Survey, low interest in this plugin prompted its removal from core v3.0 ... Learn more: https://v3.11ty.dev/docs/plugins/serverless/")`. ```