Set page title from a child template in Jade
express, node.js, pug
Solution
From https://github.com/visionmedia/jade/issues/654#issuecomment-5859502
layout.jade
block variables
!!! 5
head
- var title = title || "Default Title Here"
title #{title}
child.jade:
block variables
title = "ST"
extends layout
Problem
I'm wanting to set my page titles in the child templates of the layout via jade. I don't want to set them in the routes since that requires a server restart. Here's what I'm hoping to accomplish: layout.jade: ``` !!! 5 head - var title = title || "Default Title Here" title #{title} // ... ``` child.jade: ``` - var title = "Child Title Here" extends layout // ... ``` Any thoughts on how I can accomplish this would be a great help. Thanks!