How to Set Up Templating Engines With Express?

By Hemanta Sundaray on 2021-06-01

Templating engines are also referred to as view engines by Express.

There are two parts to setting up a templating engine in Express.

First, set the views value to specify the folder where the templates will be stored.

Second, set the view engine value to specify the template library.

// This defaults to the 'views' folder in the project root directory.
app.set("views", path.join(__dirname, "views"))

// setting up the 'pug' templating engine
app.set("view engine", "pug")

Join the Newsletter