4

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>
isari
  • 43
  • 2

1 Answers1

2

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.

HelloWorld101
  • 3,878
  • 2
  • 34
  • 47
  • Despite installing `jstransformer-handlebars`, `Error: ENOENT: no such file or directory, open 'C:\Users\myname\Documents\projectname\templates\main.hbs'` error occurs. Any ideas? – isari Feb 23 '19 at 11:39
  • 2
    Sorry, it's my stupid mistake. I placed `templates` folder wrong place. It went right, thanks. – isari Feb 23 '19 at 11:47
  • Good to hear that you were able to solve the issue. Could you please mark the answer as accepted? – HelloWorld101 Feb 25 '19 at 11:30