Categories
JavaScript Answers

How to use HTML as the view engine in Express?

Spread the love

Sometimes, we want to use HTML as the view engine in Express.

In this article, we’ll look at how to use HTML as the view engine in Express.

How to use HTML as the view engine in Express?

To use HTML as the view engine in Express, we can use the expres.static method.

For instance, we write

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

to call express.static with the path to the HTML files we want to serve.

We don’t need a view engine to render the HTML.

Conclusion

To use HTML as the view engine in Express, we can use the expres.static method.

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 *