Node Website(App), I cannot make multiple pages

I’m making a site with express using the node app template. I am not able to make multiple pages like or I’ve tried and it won’t work.


There’s a page on using routing in Express here:

But using the node-app template you could add routes for your home and about pages like so:

var express = require('express');
var app = express();

// we've started you off with Express, 
// but feel free to use whatever libs or frameworks you'd like through `package.json`.


app.get('/', function(request, response) {
  response.sendFile(__dirname + '/views/index.html');

app.get('/home', function(request, response) {
  response.sendFile(__dirname + '/views/home.html');

app.get('/about', function(request, response) {
  response.sendFile(__dirname + '/views/about.html');

// listen for requests :)
var listener = app.listen(process.env.PORT, function() {
  console.log('Your app is listening on port ' + listener.address().port);

You would need to create the home.html and about.html files in the views directory.

Note that the site would be accessible at and not as we don’t make the www sub-sub-domain available to sub-domains.

1 Like

Looks like redirects to

I’m really sorry to bring this post back up, but I tried doing this and it just said ‘Cannot GET /filenamehere/index.html’. Is there any way to stop this happening?

You might want to try going to /filename or /filename/. There is not need for index.html is you are using Express.


Thankyou! This was very helpful.

1 Like