0

I want to write my HTML in HTML. Not some fancy way. The only thing that would be cool is to be able to use some sort of include statement to include header/navigation/footer for each page.

I've looked at pug, ejs, mustache, nunchuck, etc etc. I hate all of these things. I just want to write HTML..

What is a simple node module to do this? And how do I set up the render engine in my main app.js? I am using express

1
  • Are you using the Express framework? Commented Apr 30, 2016 at 21:12

2 Answers 2

2

You can just set up your express routes to connect with html pages. Here's a simple example:

var express = require('express');

// Create express app
var app = express();

// Route index page to an index html page
app.get('/', function(req, res){
  res.sendFile(__dirname  + '/path/to/views/index.html');
});

// Create server
app.listen(8080, function(){
    console.log('Ready on port 8080...');
});

As a side note, ejs is basically html but with some bonus functionality. You can totally get away with writing only html in ejs pages and then start using the ejs features when you get comfortable with it.

Sign up to request clarification or add additional context in comments.

Comments

0

Looks like you want to server only static html files using node not some jsp equivalent dynamically generated html. Express has support for serving static files and you do not need to define any routes for that! http://expressjs.com/en/starter/static-files.html

Second thing I understood from your post is you want to include some common html to your html page. One way of doing that is to use a browser/client side java script framework. Take a look at angular.js. It has ng-include. Basically you can include one html file to another using that.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.