Search code examples
javascriptnode.jshandlebars.jsmetalsmith

Metalsmith layouts causes "no files to process" error


I conscientiously followed the tutorial on official community driven docs but failed to compile project on using Handlebars and metalsmith-layouts. "Metalsmith · no files to process" error occurred.

Here is my directory structure:

.
├── src
│   └── index.html
├── templates
│   └── main.hbs
└── build.js

build.js:

const Metalsmith = require('metalsmith');
const layouts = require('metalsmith-layouts');

Metalsmith(__dirname)
    .source('./src')
    .destination('./docs')
    .use(layouts({
        engine: 'handlebars',
        directory: 'templates'
    }))
    .build(function (err) {
        if (err) {
            throw err;
        }
    });

and main.hbs:

<h1>{{title}}</h1>

<p>
    {{contents}}
</p>

Solution

  • This is because metalsmith-layouts uses jstransformers.

    You need to install jstransformer-handlebars in order to fix the error you encountered.

    Run $ npm install --save jstransformer-handlebars and try again.