14 – HOW TO INCLUDE NAVBAR IN ALL PAGES HTML DJANGO – INVOICE MANAGEMENT SYSTEM

Spread the love

In website development, you will quickly notice that you create same links multiple times or repeatedly on different pages.

For example, if you have home.html, list_items.html, add_items.html.

If you create a link on one page, you will need to make sure you have the same link on all other pages. Therefore, on a traditional website (just HTML and CSS), you will duplicate the links on other pages.

This makes it tedious to update and maintain the website. Since you change a link name or address on one page, you will need to do it on the other pages as well.

Django has a simple solution for this by utilizing include keywords. This is what i will be showing you on this section this blog.

  1. Create a navbar.html page and add all the links (URL) to all pages of your application.
<nav>
	<li><a href="/">Home</a></li>
	<li><a href="/list_invoice">List Invoices</a></li>
	<li><a href="/add_invoice">Add Invoices</a></li>
</nav>

3. Now on every html page (template) e.g. home.html, list_items.html, add_items.html, Above the body page, add the following code to include the navbar.

{% include 'navbar.html' %} 


Spread the love

About the author

arbadjie

Hi, I'm Abdourahman Badjie, an aspiring developer with obsession for anything coding and networking. This blog is dedicated to helping people learn to develop web applications using django framework.

View all posts

2 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *