Problem statement
The /about/ and /contact/ views and routes exist, but all four templates are empty placeholders. Rather than write the full HTML page twice and keep two copies of the navbar in sync by hand, build the site on template inheritance: one base template owns the page skeleton and pulls in the navbar, and each page supplies only what is different about it.
Provided
| Route | URL name | View | Renders |
|---|---|---|---|
| GET /about/ | about | views.about | app/about.html |
| GET /contact/ | contact | views.contact | app/contact.html |
The views pass no context. No models are needed.
Requirements
Only the four files under app/templates/app/ need to change: base.html, navbar.html, about.html and contact.html. Each one currently holds a placeholder comment. How you lay out the markup is up to you, as long as the rendered pages behave as described.
1. Base template - app/base.html
- Provides the whole HTML page exactly once, so no other template has to repeat it: the output starts with <!DOCTYPE html> and has one <html lang="en">, one <head>, one <title>, one <body> and one <main>.
- Defines two blocks that pages can override:
- title: the text of the page's <title>. Default: Acme Site.
- content: everything inside <main>. Default: a single paragraph reading Content coming soon.
- Puts the navbar on every page by including app/navbar.html once, outside <main>.
2. Navbar partial - app/navbar.html
- Contains only the navbar: an element with the id site-nav (a <nav> is the natural choice) holding two links, About to the about page and Contact to the contact page.
- Build the link targets from the URL names about and contact, not typed paths, so the links still work if the pages move to different URLs.
- The navbar exists only in this file. The base includes it and the pages never include or repeat it, so editing this one file changes every page.
3. Pages - app/about.html and app/contact.html
- Each page extends app/base.html and only overrides blocks; it repeats no skeleton markup and no navbar.
- About page: title About Us; the content is an <h1> reading Who we are followed by any paragraph text you like.
- Contact page: title Contact Us; the content is an <h1> reading Get in touch followed by any paragraph text you like.
4. Defaults
- A template that extends the base without overriding a block gets the base default for that block: Acme Site for the title, the Content coming soon. paragraph for the content.
How markup is matched. Each element is found by its id or class, and only its text counts, with runs of whitespace collapsed to one space. Extra attributes and classes, wrapper elements, and tags inside an element (such as <strong>) are all fine; only the element's text must match exactly.
Sample Requests & Responses
GET /about/ returns 200:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>About Us</title>
</head>
<body>
<nav id="site-nav">
<a href="/about/">About</a>
<a href="/contact/">Contact</a>
</nav>
<main><h1>Who we are</h1>
<p>We build small, reliable tools.</p>
</main>
</body>
</html>
GET /contact/ returns 200 with the same skeleton and navbar, <title>Contact Us</title>, and <h1>Get in touch</h1> inside <main>.
A template that only extends the base renders the same skeleton and navbar with <title>Acme Site</title> and <main><p>Content coming soon.</p></main>.
