Django templates are very powerful for speeding up a website prototype, e.g., template literals, template filters, and template inheritance. Especially, the template inheritance, makes it much easier to build a multi-page web application with minimal code repetition.
I personal have developed the following webpage structure based on the template inheritance as a best practice.
- First of all, the overall and simplified web application can be decomposed into primitive blocks as the following figure shows.
![]()
Namely, MAIN_HEADER, SIDEBAR, Breadcrumb, message, BODY_CONTENT and FOOTER. Where, MAIN_HEADER includes children blocks LOGO, MESSAGES (hub) and Account_bar.
- With this design pattern, the HTML markup blocks can be configured as a
base.htmlas following
![]()
It acts as an abstract base structure of the website.
- I added another layer to wrap up a
site_base.htmlto extend thebase.htmlas the webpage base for all pages. This one includes static file blocks. Pay attention to the colored items.
![]()
- For an actual page, e.g.
home.htmlorabout.html, it extents thesite_base.htmlwith block implementations.
In this way, a multi-page website can be effectively developed.