DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Cover image for Day 26 – Working with EJS (Part 3) - Learning Node JS In 30 Days [Mini series]
Muhammad Ali (Nerdjfpb)
Muhammad Ali (Nerdjfpb)

Posted on • Originally published at blog.nerdjfpb.com

Day 26 – Working with EJS (Part 3) - Learning Node JS In 30 Days [Mini series]

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.

Alt Text

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

Alt Text

Let’s add the footer also

Alt Text

Now we can easily use this partial parts easily

Alt Text

See the result

Alt Text

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

You can see the graphical version here

Originally it published on nerdjfpbblog. You can connect with me in twitter or linkedin !

You can read the old posts from this series (below)

Top comments (0)

12 Gorgeous UI Components for Your Design Inspiration

>> Check out this classic DEV post <<