Exercise 2.4D: Inherited Layouts to Simplify Templates

Purpose: Improve modularization by adding inherited templates. Inherited templates have become popular because they create cleaner code and stronger separation of concerns. In the case of this project part, you should feel the difference as the template files become smaller and less repetitive.

Create the Layout

Create templates/common/layout.html and put in all common structure and shared element content (e.g. HTML <head>, <nav>, and <footer>, and an inheritable block for <main>).

Inherit the Layout

Simplify your content HTML files (home.html, professionals.html, services.html, contact.html) by using the Jinja {% extends %} blocks to inherit the layout file and {% block %} blocks to insert the unique content of each page.

Test your Project

By the end of this step, your project should work, delivering the same content as Project Part 1.