Homepage with Navbar

Learn how to add a navbar in the homepage and use block tags in the Django web app.

In this chapter, we will focus on adding a navbar with links to the other pages. This means we’ll no longer have to keep typing out the URL for the pages.

The first step in adding a navbar is to create a file called base.html in the templates folder which will serve as our parent template. This means that we’ll pass this template to other pages since it has common elements for all pages such as a navbar.

When we style the website, we will include a fully functional navbar. For now, let’s just display the links for the other pages at the top, so that users can navigate the website easily.

Add navbar

Go to listings/templates/listings/ directory, open base.html and add the following code.

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy