CARVIEW |
Select Language
HTTP/2 200
access-control-allow-origin: *
age: 0
cache-control: public, max-age=0, must-revalidate
content-disposition: inline; filename="ejs"
content-encoding: gzip
content-type: text/html; charset=utf-8
date: Wed, 15 Oct 2025 01:08:10 GMT
etag: W/"0fdbedac887b14a192f97d46aeb4d7a4"
last-modified: Wed, 15 Oct 2025 01:08:10 GMT
server: Vercel
strict-transport-security: max-age=63072000
x-vercel-cache: HIT
x-vercel-id: bom1::h2tfw-1760490489690-6e8360193738
EJS — Eleventy
- Stable
3.1.2
- Canary
4.0.0-alpha.4
- Guide
Guide
- Plugins
- Services
EJS
Template Languages:
On this page
Eleventy Short Name | File Extension | npm Package |
---|---|---|
ejs |
.ejs |
ejs |
You can override a .ejs
file’s template engine. Read more at Changing a Template’s Rendering Engine.
Installation
The ejs
templating language was moved out of Eleventy core in v3 and now requires a plugin installation.
Add to your configuration file:
eleventy.config.js
import ejsPlugin from "@11ty/eleventy-plugin-ejs";
export default function (eleventyConfig) {
eleventyConfig.addPlugin(ejsPlugin);
}
const ejsPlugin = require("@11ty/eleventy-plugin-ejs");
module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(ejsPlugin);
}
Use more ejs
options (full options list):
eleventy.config.js
import ejs from "ejs";
import ejsPlugin from "@11ty/eleventy-plugin-ejs";
export default function (eleventyConfig) {
eleventyConfig.addPlugin(ejsPlugin, {
async: false, // default
// use <? ?> instead of <% %>
delimiter: "?",
// Override the `ejs` library instance
eleventyLibraryOverride: ejs,
});
}
const ejs = require("ejs");
const ejsPlugin = require("@11ty/eleventy-plugin-ejs");
module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(ejsPlugin, {
async: false, // default
// use <? ?> instead of <% %>
delimiter: "?",
// Override the `ejs` library instance
eleventyLibraryOverride: ejs,
});
}
Supported Features
Feature | Syntax |
---|---|
✅ Include (Preprocessor Directive) | <% include /user/show %> looks for _includes/user/show.ejs (the leading slash is important). Does not process front matter in the include file. |
✅ Includes (Relative Path, Preprocessor Directive) | Relative paths in ejs can leave off the leading slash / or use ./ to use the template’s directory or ../ for the template’s parent directory:<% include 'user/show' %> or <% include './user/show' %> looks for ./user/show.ejs from the template’s current directory. Does not process front matter in the include file. |
✅ Include (pass in Data) | <%- include('/user/show', {user: 'Ava'}) %> looks for _includes/user/show.ejs . Does not process front matter in the include file. |
✅ Include (Relative Path, pass in Data) | Relative paths in ejs can leave off the leading slash / or use ./ to use the template’s directory or ../ for the template’s parent directory:<%- include('user/show', {user: 'Ava'}) %> or <%- include('./user/show', {user: 'Ava'}) %> looks for ./user/show.ejs from the template’s current directory. Does not process front matter in the include file. |