Closed mcapodici closed 3 years ago
I had the same issue and here is how I fixed it.
jstransformer-handlebars
is now a dependency that is not installed through metalsmith-layouts
Under the hood this plugin uses
jstransformers
to render your layouts. Since there are over a 100jstransformers
we don't install them automatically, so you'll need to install the jstransformer for the language you want to use. For example, to render handlebars you would installjstransformer-handlebars
, etc.
npm install jstransformer-handlebars --save
jstransformer-handlebars
expects the template files extensions to be hbs
so you must rename all the *.html
files in the layouts
folder to *.hbs
.
You must now also update the layout
property in the YAML front-matter of all the *.md
files in the src
folder. For example, in first-post.md
- layout: post.html
+ layout: post.hbs
It will work then! So, yes: you should probably raise an issue with https://github.com/segmentio/metalsmith to upgrade their example.
Apologies for the (very) late response. @madooei's right, the example should be updated. It's one of the things we really need to tackle for this project. In the meantime, the readmes and wikis of layouts and in-place are accurate and are the best place to start when you're looking for examples.
I'll close this, but feel free to respond if anything's unclear.
Just got stuck on this too - couldn't for the life of me figure out why I was following the static site example perfectly and it just wasn't working.
It would be great if the example could be updated so it works with the latest versions of everything!
To reproduce:
This works, now edit
package.json
and replace"metalsmith-layouts": "^1.4.1"
with"metalsmith-layouts": "^2.0.0"
Result:
Obviously being a major version upgrade there could be a breaking change, but I couldn't see what from the release notes. If there is a breaking change I can raise an issue with https://github.com/segmentio/metalsmith to upgrade their example.