Creating the Navigation Template
00:00 Consistent navigation is very important for user experience. Creating a separate navigation template promotes reusability and makes sitewide updates easier.
00:11 Imagine having to change a link on every single page of your website if you added a new section. You’d have to make changes to the navigation section in each and every page.
00:21 A separate navigation template solves this problem. Change it once and the change reflects everywhere. Now let’s go ahead and create your navigation template.
00:33
In the templates
folder, create a new file called _navigation.html
. You use an underscore to indicate that this is a partial template meant to be included in other templates.
00:46 In this file, we write the code for your navigation menu.
00:53
Note that _navigation.html
contains neither an {% extends %}
tag nor any block tags. You can focus solely on how you want to render your navigation menu.
01:04
Again, url_for()
generates the URLs for your home and about pages, ensuring correctness.
01:13 You have added links to your home and about pages within the navigation template. As you add more pages to your application, you would simply add more list items with links in the navigation template, and they would automatically appear on every page that includes this navigation template.
Become a Member to join the conversation.