Categories
JavaScript Answers

How to use HTML as the view engine in Node.js Express?

Spread the love

To use HTML as the view engine in Node.js Express, we use the express.static middleware.

For instance, we write

app.use(express.static(__dirname + "/public"));

to make the /public folder in the project folder a static file directory.

Then we can put HTML files in there and open them directly.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *