I do not want Jade or EJS on my site. How can I create an express site without it defaulting to the Jade templates? Thanks
Luckily, Express. js provides us a way to create dynamic HTML pages from our server-side applications through a template engine. A template engine works in a rather simple manner: you create a template and, with the appropriate syntax, pass variables into it.
A template engine enables you to use static template files in your application. At runtime, the template engine replaces variables in a template file with actual values, and transforms the template into an HTML file sent to the client. This approach makes it easier to design an HTML page.
Some popular template engines that work with Express are Pug, Mustache, and EJS. The Express application generator uses Jade as its default, but it also supports several others.
Popular template engines The popular ones include Ejs, Jade, Pug, Mustache, HandlebarsJS, Jinja2, and Blade.
If what you want is directly to serve static html files with the possibility to cache resources, while still being able to hit "/" and get index.html, then the answer is as easy as this:
var express = require('express'); var http = require('http'); var app = express(); app.use(express.static(__dirname + '/public')); http.createServer(app).listen(3000);
Gotcha: Html files including index.html must be inside /public folder instead of /views
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With