6.3 Using the url Template Tag to Build a Navigation Menu

Before we generate the URLs for the links we have already left blank, we’re going to add to the work we must do.

A standard design feature of modern websites is a navigation menu. Navigation menus allow for easier site navigation and are typically necessary to provide a good user experience. In this section, we create a navigation menu and then use the url template tag to generate the links in the menu.

Had we programmed every template independently, we would now be faced with the task of changing every template. However, because we built our templates with inheritance via the extends template tag, we can make a single change to our site-wide template, found in /templates/base.html.

Get Django Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.