How To Change Template Engine In Express.js

If you don’t have a view engine set in your express/node application, you need to specify file extension with each of your view files. To fix this issue you need to set a default view engine for rendering views.

You can set a template engine using following code.

app.set('view engine', 'jade')

The above code will set Jade as the default template engine. You can change jade with your own templating engine. For example, if you wish to set ejs as your default template engine, use following code.

app.set('view engine', 'ejs')

Read Also: How to use EJS in Express

Leave a Comment.