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

Can't Pass Challenge Task 4 of 6 (template blocks) in Flask Basics

I am stuck (can't get it to pass) in "Flask Basics" - Challenge Task 4 of 6 Put the contents of the tag in "index.html" into the title block.

(I passed 1-3, by the way)

I get this error message: Bummer: Didn't find the right content in the rendered template.

This is my flask_app.py file code (for step 4):

from flask import Flask
from flask import render_template

app = Flask(__name__)


@app.route('/')
def index():
    return render_template('index.html')

This is my index.html file code (for step 4):

{% extends "layout.html" %}

<!doctype html>
<html>
  <head>{% block title %}Homepage{% endblock %}</head>
<body>
{% block content %}
<h1>Smells Like Bakin'!</h1>
<p>Welcome to my bakery web site!</p>
{% endblock %}
</body>
</html>

This is my layout.html file code (for step 4):

<!doctype html>
<html>
<head>{% block title %}Smells Like Bakin'{% endblock %}</head>
<body>
{% block content %}{% endblock %}
</body>
</html>

I've tried every conceivable rewriting of the code (based on answers in the forums) and NOTHING passes.

Can anyone help me get passed this!?!

Thanks for any/all help!

flask_app.py
from flask import Flask
from flask import render_template

app = Flask(__name__)


@app.route('/')
def index():
    return render_template('index.html')
templates/index.html
{% extends "layout.html" %}

<!doctype html>
<html>
  <head>{% block title %}Homepage{% endblock %}</head>
<body>
{% block content %}
<h1>Smells Like Bakin'!</h1>
<p>Welcome to my bakery web site!</p>
{% endblock %}
</body>
</html>
templates/layout.html
<!doctype html>
<html>
<head>{% block title %}Smells Like Bakin'{% endblock %}</head>
<body>
{% block content %}{% endblock %}
</body>
</html>

2 Answers

Hi Peter

It's been a while since I've taken this course at Treehouse but I managed to get pass this challenge (task 4 of 6) by replacing the third line in your templates/layout.html file as follows:

<!doctype html>
<html>
<head><title>{% block title %}Smells Like Bakin'{% endblock %}</title></head>
<body>
{% block content %}{% endblock %}
</body>
</html>

So, in short, I added a pair of <title></title> tags there.

Hope this helps!

Hello Ave

Thanks for the answer. It worked! And yes, it certainly helped! I have now completed and gotten past that particular code challenge...

Thanks again!

Hello Peter

I am really glad to hear that - happy to help!

Good luck with your studies!