Create New Page
In this guide we will see how we can create a new page and render it through a path.
Step 1: Using our ejs structure first create an ejs page you want to render.
Step 2: Import the dependencies require to render the template in the routes/index.js
file.
var express = require('express');
Step 3: Create a route and give it a function to return the template that you have just
created.
router.get('/', function (req, res) {
res.render('index', { layout: false });
});
If you want a page which includes breadcrumbs, header, footer, you can extend layout.ejs and pass required variables while defining the routes. An example is given below
router.get('/', function (req, res) {
res.render('index', { breadcrumbName: 'name', breadcrumbPath: 'subName' });
});
When we have a theme this big, number of routes increase reapidly, so to make it more easier to define routes, we have created an array of object, which contains name of the page and all required variables and loop through that array to define routes.
var withOutLayoutPageData = [
{ name: 'box-layout', breadcrumbData: { name: 'Page Layout', subName: 'Box Layout' } },
{ name: 'layout-rtl', breadcrumbData: { name: 'Page Layout', subName: 'RTL' } },
{ name: 'layout-dark', breadcrumbData: { name: 'Page Layout', subName: 'Dark Layout' } },
{ name: 'hide-on-scroll', breadcrumbData: { name: 'Page Layout', subName: 'Hide Menu On Scroll' } },
{ name: 'footer-dark', breadcrumbData: { name: 'Page Layout', subName: 'footer dark' } },
{ name: 'footer-fixed', breadcrumbData: { name: 'Page Layout', subName: 'footer fix' } },
];
Thats all you have to do, now you can access the page through the new path that you have created