Skip to navigation Skip to main content
Eleventy
Eleventy Documentation
Stable
3.0.0
Toggle Menu
Eleventy 1.93s
Gatsby 29.05s

Command Line Usage

Prerequisites
  1. Eleventy runs in a Terminal application. Well, wait—what is a Terminal?
  2. Have you already installed Eleventy?

Here’s the first command you can enter in your Terminal application to run Eleventy:

npm pnpm yarn
# Searches the current directory, outputs to ./_site
npx @11ty/eleventy

# `npx @11ty/eleventy` is the same as:
npx @11ty/eleventy --input=. --output=_site
# Searches the current directory, outputs to ./_site
pnpm exec eleventy

# `pnpm exec eleventy` is the same as:
pnpm exec eleventy --input=. --output=_site
# Searches the current directory, outputs to ./_site
yarn exec eleventy

# `yarn exec eleventy` is the same as:
yarn exec eleventy --input=. --output=_site

Read more about --input and --output. Note that setting the input and output directories via config file is preferred.

A hypothetical template.md in the current directory would be rendered to _site/template/index.html. Read more at Permalinks.

npm pnpm yarn
# Use only a subset of template types
npx @11ty/eleventy --formats=md,html,ejs

# Don’t process any formats
npx @11ty/eleventy --formats=

# Find out the most up-to-date list of commands (there are more)
npx @11ty/eleventy --help
# Use only a subset of template types
pnpm exec eleventy --formats=md,html,ejs

# Don’t process any formats
pnpm exec eleventy --formats=

# Find out the most up-to-date list of commands (there are more)
pnpm exec eleventy --help
# Use only a subset of template types
yarn exec eleventy --formats=md,html,ejs

# Don’t process any formats
yarn exec eleventy --formats=

# Find out the most up-to-date list of commands (there are more)
yarn exec eleventy --help
  • The default for --formats= changed in v3.0.0 from an alias of * to an empty set.

Re-run Eleventy when you save

npm pnpm yarn
# Add a web server to apply changes and
# refresh automatically. We’ll also --watch for you.
npx @11ty/eleventy --serve

# Change the web server’s port—use localhost:8081
npx @11ty/eleventy --serve --port=8081

# Watch and re-run when files change, without the web server.
npx @11ty/eleventy --watch
# Add a web server to apply changes and
# refresh automatically. We’ll also --watch for you.
pnpm exec eleventy --serve

# Change the web server’s port—use localhost:8081
pnpm exec eleventy --serve --port=8081

# Watch and re-run when files change, without the web server.
pnpm exec eleventy --watch
# Add a web server to apply changes and
# refresh automatically. We’ll also --watch for you.
yarn exec eleventy --serve

# Change the web server’s port—use localhost:8081
yarn exec eleventy --serve --port=8081

# Watch and re-run when files change, without the web server.
yarn exec eleventy --watch

--quiet if the Output is Too Noisy

npm pnpm yarn
# Shhhhh—Don’t log so much to the console
npx @11ty/eleventy --quiet
# Shhhhh—Don’t log so much to the console
pnpm exec eleventy --quiet
# Shhhhh—Don’t log so much to the console
yarn exec eleventy --quiet

--dryrun to do a Little Testing

Runs without writing to the file system. Useful when debugging.

npm pnpm yarn
# Run Eleventy but don’t write any files
npx @11ty/eleventy --dryrun
# Run Eleventy but don’t write any files
pnpm exec eleventy --dryrun
# Run Eleventy but don’t write any files
yarn exec eleventy --dryrun

--config to Change the Config file name

npm pnpm yarn
# Override the default eleventy project config filename (.eleventy.js)
npx @11ty/eleventy --config=myeleventyconfig.js
# Override the default eleventy project config filename (.eleventy.js)
pnpm exec eleventy --config=myeleventyconfig.js
# Override the default eleventy project config filename (.eleventy.js)
yarn exec eleventy --config=myeleventyconfig.js

Read more about Configuration files.

Added in v3.0.0If your specified --config file does not exist, Eleventy will throw an error.

--to can output JSON

npm pnpm yarn
# Output a JSON structure (does not write to the file system)
npx @11ty/eleventy --to=json

# Output a Newline Deliminated JSON structure (does not write to the file system)
npx @11ty/eleventy --to=ndjson

# Default behavior (Output to file system)
npx @11ty/eleventy --to=fs
# Output a JSON structure (does not write to the file system)
pnpm exec eleventy --to=json

# Output a Newline Deliminated JSON structure (does not write to the file system)
pnpm exec eleventy --to=ndjson

# Default behavior (Output to file system)
pnpm exec eleventy --to=fs
# Output a JSON structure (does not write to the file system)
yarn exec eleventy --to=json

# Output a Newline Deliminated JSON structure (does not write to the file system)
yarn exec eleventy --to=ndjson

# Default behavior (Output to file system)
yarn exec eleventy --to=fs

Read more about ndjson.

--incremental for Partial Incremental Builds

npm pnpm yarn
# *Repeat* builds only operate on files that have changed
npx @11ty/eleventy --watch --incremental
npx @11ty/eleventy --serve --incremental

# Skip the initial full build with `--ignore-initial`
npx @11ty/eleventy --serve --incremental --ignore-initial

# Pass in a template path, watch/serve not required
# Added in v3.0.0
npx @11ty/eleventy --incremental=myfile.md
# *Repeat* builds only operate on files that have changed
pnpm exec eleventy --watch --incremental
pnpm exec eleventy --serve --incremental

# Skip the initial full build with `--ignore-initial`
pnpm exec eleventy --serve --incremental --ignore-initial

# Pass in a template path, watch/serve not required
# Added in v3.0.0
pnpm exec eleventy --incremental=myfile.md
# *Repeat* builds only operate on files that have changed
yarn exec eleventy --watch --incremental
yarn exec eleventy --serve --incremental

# Skip the initial full build with `--ignore-initial`
yarn exec eleventy --serve --incremental --ignore-initial

# Pass in a template path, watch/serve not required
# Added in v3.0.0
yarn exec eleventy --incremental=myfile.md

Read more about incremental builds. Related GitHub #3324

--ignore-initial to run Eleventy without an Initial Build Added in v2.0.0

Be wary of any file changes that happened while Eleventy wasn’t running!

npm pnpm yarn
# Don’t build when Eleventy starts, only build on file changes
npx @11ty/eleventy --watch --ignore-initial
npx @11ty/eleventy --serve --ignore-initial

# Works great with Incremental
npx @11ty/eleventy --serve --incremental --ignore-initial
# Don’t build when Eleventy starts, only build on file changes
pnpm exec eleventy --watch --ignore-initial
pnpm exec eleventy --serve --ignore-initial

# Works great with Incremental
pnpm exec eleventy --serve --incremental --ignore-initial
# Don’t build when Eleventy starts, only build on file changes
yarn exec eleventy --watch --ignore-initial
yarn exec eleventy --serve --ignore-initial

# Works great with Incremental
yarn exec eleventy --serve --incremental --ignore-initial

Using the Same Input and Output

Yes, you can use the same input and output directories, like so:

npm pnpm yarn
# Parse and write Markdown to HTML, respecting directory structure.
npx @11ty/eleventy --input=. --output=. --formats=md
# Parse and write Markdown to HTML, respecting directory structure.
pnpm exec eleventy --input=. --output=. --formats=md
# Parse and write Markdown to HTML, respecting directory structure.
yarn exec eleventy --input=. --output=. --formats=md
WARNING:
Careful with --formats=html here! If you run Eleventy more than once, we will attempt to process your new output files as input files (which will throw errors). Read more at the HTML template docs.

Other pages in Getting Started: