How to use partials in Express.js layout?

express, node.js

Solution

Yes.

<% include path/to/template %>

Documentation here. https://github.com/visionmedia/ejs#includes

Problem

I have a layout.ejs file that contains my site's basic boilerplate HTML markup: doctype declaration, head, body, footer, the basics... How would I go about placing the navigation in a separate partial file and including it into this layout? Is there a particular require() or include() function for doing this? I am using EJS view engine.

Original source