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 trialdd710
24,896 PointsCan'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
MUZ140734 Tinashe Chibwe
16,960 PointsSeems this challenge is sensitive to whitespace(spacing). Tried same answer without spacing, it failed...only to pass after adding spacing.
Ary de Oliveira
28,298 Pointstask 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
Treehouse Guest TeacherThis 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.
dd710
24,896 PointsThanks 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%}
Miguel de Luis Espinosa
41,279 PointsI 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
Treehouse Guest TeacherYou should be able to pass now. I didn't account for such a compacted version.
Miguel de Luis Espinosa
41,279 PointsThank you! Kenneth Love . That was quick; I do appreciate your help, especially on a Saturday.
Valentin Famelart
19,190 PointsI 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
Treehouse Guest TeacherHmm, 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.
Valentin Famelart
19,190 PointsIt 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
Courses Plus Student 12,154 PointsBummer! 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
Treehouse Guest TeacherThe 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.