Congratulations, this concludes the lesson on Flask templates. In this lesson we:

  • Created a file structure that works with the Jinja2 template engine
  • Rendered pages in our browser using files called templates
  • Shared our application data for use within templates
  • Applied filters to our data within our templates
  • Utilized if statements to bring decision making to our templates
  • Implemented for loops to perform repetitive tasks in our templates
  • Moved common content to separate files to be shared by many templates

To show the power of what we have learned let’s add a simple navigation bar to the app.



Things added to our app are:

  • an “about” route in app.py
  • an about.html template inheriting from base.html
  • the ‘Back To Recipe List’ link has been removed from recipe.html

Let’s create a navigation bar that will link to the about page and the index page. In base.html add the following content just inside the <body> tag.

<div> <a href="/">Recipes</a> | <a href="/about">About</a> </div>

Once complete run the code and you’ll see that each page in the site now has a simple navigation bar including the new ‘About’ page.

Great work!

Sign up to start coding

By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.
Already have an account?