Creating the base layout file
Up to this point, everything we’ve accomplished with 11ty can be replicated in other, smaller tools. Removing the basic HTML boilerplate from each page makes the code much more maintainable and extensible.
To start, we need a new subdirectory in the src
directory. Name this directory _templates
. By default, 11ty uses an _includes
directory for includes and layouts. To avoid semantic confusion, we’ll update our configuration to use the new directory instead.
A note on directory naming
It’s perfectly fine to use the default folder names. Most of my 11ty projects use the _includes
naming convention. This step is more for clarity than best practices.
In the configuration function’s return
statement, update the dir
object to include an includes
property:
module.exports = function(eleventyConfig) { // Copy `assets/` to `_site/assets/` eleventyConfig.addPassthroughCopy...