Skip to navigation Skip to main content
Eleventy
Eleventy Documentation
Stable
2.0.1
Toggle Menu
Eleventy 5.81s
Gatsby 43.36s

Configuration Shapes

You can learn more about the default file names for configuration files.

Callback Function

Callback functions are the preferred method for configuration files and allow you further customization options using Eleventy’s full Configuration API helper methods.

Added in v3.0.0Support for ESM and Asynchronous callbacks was added in Eleventy v3.0.

eleventy.config.js
export default async function(eleventyConfig) {
// Access to the full `eleventyConfig` Configuration API
};
module.exports = async function(eleventyConfig) {
// Access to the full `eleventyConfig` Configuration API
};

Optional: Export config Object

eleventy.config.js
module.exports = async function(eleventyConfig) {};

module.exports.config = {
dir: {
input: "views",
output: "dist"
}
};
export default async function(eleventyConfig) {};

export const config = {
dir: {
input: "views",
output: "dist"
}
};

Optional: Return Object

Instead of exporting a config object with your static options, you can return this same object in your configuration callback (though it is not preferred for order-of-operations reasons).

eleventy.config.js
export default async function(eleventyConfig) {
return {
dir: {
input: "views",
output: "dist"
}
};
};
module.exports = async function(eleventyConfig) {
return {
dir: {
input: "views",
output: "dist"
}
};
};

Export Default Object

You can export your static options as the top level default export too, though configuration callback functions are preferred as they allow you to access the full Configuration API.

eleventy.config.js
export default {
dir: {
input: "views"
}
}
module.exports = {
dir: {
input: "views"
}
}

Other pages in Configuration: