I am starting a series on node js. Actually I’m not super skilled with node js. So I thought let’s start from zero again and help others with me to learn about it. I saw the ‘the net ninja’ tutorials and took the syllabus from there and make a fusion of my own. I want to help you with my journey, let’s ride together into node js for 30 days…

Day 26 — Working with EJS — Part 3— Learning Node JS In 30 Days [Mini series]

A full series to learn the basics easily of node js

Muhammad Ali

--

We already know about templating engine right? Now tell me one thing, if you have 10 pages, how you’ll handle the navbar ? Can we reuse the navbar for every page ?

Answer is YES. We can but we need to make the navbar as partials. Partials is a concept in ejs

So create a folder inside our view folder call it partials. We’ll store the partial files here.

Let’s start creating from head files. Like the cdn’s we are going to use. Let’s try bootstrap in our case.

I’m using the navbar from bootstrap 4 too. https://getbootstrap.com/docs/4.4/components/navbar/

Let’s add the footer also

Now we can easily use this partial parts easily

See the result

Do you understand how we can easily do many things using partial templating ?

--

--

No responses yet