Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Flask Basics Templates and Static Files Template Inheritance

Can't pass challenge 5 of 6 in Flask; Templates and Static Files

I'm stuck on this one but I think my answer is correct, can anyone lend any insight?

Remove everything from "index.html" except for the extends and block tags and their contents.

Bummer! Your "index.html" template seems to have extra content in it.

(sorry for some reason it wouldn't attach the correct file)

My Code for index.html below:

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

7 Answers

Seems this challenge is sensitive to whitespace(spacing). Tried same answer without spacing, it failed...only to pass after adding spacing.

task 1 from flask import Flask from flask import render_template

app = Flask(name)

@app.route('/') def index():

return render_template('index.html')

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

</html>

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

</html>

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

task 3 templates/index.html

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

task 4 template/index.html

Put the contents of the <title> tag in "index.html" into the title block.

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

</html>

task 5

Remove everything from "index.html" except for the extends

and block tags and their contents.

template/index.html

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

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

</html>

task 6

{% block title %}{{ super() }} Homepage{% endblock %}

====================

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

This may be another instance of my validation being too picky. Let me check it out.

EDIT: Yep, that was it. Fixed it and you should be able to pass now.

For the record, it was the extra spacing you had around your <title> tags, I think.

Thanks a lot!

I just tried the exercise again with the following code and its still giving me the same error

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

I also get the same error and I can't minimize the code any further.

{%extends "layout.html"%}{%block title%}Homepage{%endblock%}{%block content%}<h1>Smells Like Bakin'!</h1><p>Welcome to my bakery web site!</p>{%endblock%}
Kenneth Love
Kenneth Love
Treehouse Guest Teacher

You should be able to pass now. I didn't account for such a compacted version.

Thank you! Kenneth Love . That was quick; I do appreciate your help, especially on a Saturday.

I personnaly had the same issue later this day (France time)

Basically, I managed to work around by typing my code step by step. For my first try, I wrote everything down in a row, doing more than asked. I ended up doing what I should have done at the end of the challenge. Except that I don't know how, the tester kept throwing me this error. I did everything from scratch, sticking to the questions and it passed quite fine. I had the same code during both tries

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

Hmm, sorry you had an issue with it. If you can replicate the errors w/ good code, send it to me and I'll see about getting it fixed.

It was the same good code you wrote in your video. It seems the only problem is that I minified it too early. I'll check again

EDIT : Well it looks that everything is working nice for me now. Thanks again :)

Zachary Hudson
PLUS
Zachary Hudson
Courses Plus Student 12,154 Points

Bummer! Your "index.html" template seems to have extra content in it. Can't get this thing to pass at all. I've even tried code from this forum post directly.

index page is:

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

layout page is:

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

What am I doing wrong?

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

The last step is:

Finally, change the "index.html" <title> tag to be: {{ super() }} Homepage. Make sure there's a space before "Homepage".

Your <title> tag doesn't have the {{ super() }} call in it.