Include Module:
let ejsLayouts = require(`express-ejs-layouts`)
Add Layout File: In your
views folder,
add a new file called
layout.ejs, and add a template to
be used for every page. Put
defineContent where the
page-specific content should appear:
<html>
<head>
<title>Your Title</title>
</head>
<body>
<h1>Your Heading</h1>
<%- defineContent(`main`) %>
</body>
</html>
Use Layout File: In your HTML for a specific page,
remove all site-wide content, and put
contentFor at the
top of the file:
<%- contentFor(`main`) %>