Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Including Layout Problem in express-handlebars

Have you any Idea what's wrong here? When I run a view file in a single page Its run fine but when I add external layout in this template its generate an error. What do you think what is the problem in this code?

const expressHbs = require('express-handlebars');
app.engine(
    expressHbs({
      extname: "hbs",
      defaultLayout: "main-layouts",
      layoutsDir: "views/layouts"
    })
  );
  app.set('view engine', 'hbs');
like image 981
Md Sabbir Hossain Avatar asked Mar 16 '26 10:03

Md Sabbir Hossain


1 Answers

Try this, hope your issue would be solved:

app.engine(
    "hbs",
    expressHbs({
      extname: "hbs",
      defaultLayout: "main-layouts",
      layoutsDir: "views/layouts"
    })
  );
like image 199
Dipta Das Avatar answered Mar 19 '26 01:03

Dipta Das