Skip to navigation Skip to main content
11ty Logo Sustainability Fundraising
Eleventy
Eleventy Documentation
Stable
2.0.1
Canary
3.0.0-alpha.16
Toggle Menu
Eleventy 5.81s
Gatsby 43.36s

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 a config file is more reliable, especially when using tools like netlify dev.

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

# 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

# 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

# Find out the most up-to-date list of commands (there are more)
yarn exec eleventy --help

Re-run Eleventy when you save Jump to heading

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 Jump to heading

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 Jump to heading

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 Jump to heading

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

--to can output JSON Added in v1.0.0 Jump to heading

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 Jump to heading

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
# *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
# *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

Read more about incremental builds.

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

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 Jump to heading

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, it’ll try to process the output files too. Read more at the HTML template docs.

Other pages in Getting Started: