node.js express set title

Specifying the page title in the route is easiest method.

This example shows the index.js file in my routes folder.. which is the default set by Express.

/* GET home page. */
router.get('/', function(req, res, next) {
  res.render('index', { title: 'Page Title' });
});

simple.jade:

!!! 5
 title= title

express application:

app.get('/simple',function(req,res) {
    res.render('simple',{title='mytitle'});
}

This is what I did and it worked for me. The example uses a hypothetical "videos" view that needs a title to be "video gallery", adjust accordingly.

layout.jade //This is added by default in express apps

doctype html
html
  head
    title= title
    link(rel='stylesheet', href='/stylesheets/style.css')
  body
    block content

videos.jade //You can create a view such as this

extends layout

block content
  h1= title

app.js //The file is default but you must add a route like this. And set the title

app.get('/videos/', function(req, res){
  res.render('videos', {
    title: 'Video Gallery'
  });
});