Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Flask Basics Templates and Static Files Template Inheritance

Sam Akers
Sam Akers
4,744 Points

Can't extend "layout.html"

For some reason I can only see "Hello from Sam" printed on the page.

"Brought to you by the fine folks at Treehouse!" does not render at all.

Within the templates folder I have add.html ,index.html and layout.html

Outwith this folder is app_flask.py

index.html

{% extends "layout.html" %}

{% block title %}Howdy!{% endblock %}

{% block content %}
<h1>Hello from {{ name }}!</h1>
{% endblock %}

layout.html

<!DOCTYPE html>
<html>
  <head>
    <title>{% block title %}{% endblock %}</title>
  </head>
  <body>
    {% block content %}{% endblock %}
    <p>Brought to you by the fine folks at Treehouse!</p>
  </body>
</html>

Copied your you files exactly as you have typed and I seem to get a different result. With that in mind I think your code is probably correct, which leads me to think that you should try one of the two things first

  1. Copy the code from here and save each file and then reload if you are still running app.py or
  2. Restart your dev server (which is just CTRL + C) and then run python app.py again