If you want to use virtual templates in an eleventy project, you have to use eleventy 3 or greater. But note that the feature landed – officially, at any rate – in 3.0 beta. In other words, 3.0 alpha is not necessarily good enough, as I learned today.[✲]
I was running 11ty version 3.0.0-alpha.5, as specified
in my project’s package.json
:
{
"main": "eleventy.config.js",
"dependencies": {
"@11ty/eleventy": "3.0.0-alpha.5"
}
}
If memory serves, that’s because when I first upgraded to
3.x, only an alpha version was available.
Whatever the reason, when I tried addTemplate
, 11ty
threw an error:
eleventyConfig.addTemplate is not a function
.
After upgrading @11ty/eleventy – by entering
npm install @11ty/eleventy
at a terminal prompt –
my package.json
file was changed:
{
"main": "eleventy.config.js",
"dependencies": {
"@11ty/eleventy": "^3.0.0"
}
}
And the error disappeared.