mjgs / ejs-layouts-using-includes

Minimal example showing how to create pages using a common EJS layout

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

EJS layouts using includes

EJS doesn't have a layouts feature but it's actually possible to implement layouts using the includes feature as described in the docs. This is a slightly more detailed example, using express and a variable to set the path to the template, that shows how to implement a common layout across pages.

npm install
npm start

Then load the following urls which are both using views/layout.ejs:

http://localhost:3000/page1

http://localhost:3000/page2

[Note that you can set another port using PORT env variable]

About

Minimal example showing how to create pages using a common EJS layout

License:MIT License


Languages

Language:JavaScript 62.6%Language:HTML 27.4%Language:CSS 10.0%