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 trialDanielle Murray
Python Development Techdegree Graduate 7,755 PointsHi could you please urgently help me pass this task, i'm struggling to understand how to add the link properly
Especially in layout.html. Your help would be much appreciated.
{% extends "layout.html" %}
<a href="http://Contact.com">anchored text</a>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="Treehouse code chalenge practice.">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<h1>Practice Template Inheritance</h1>
{% block link %}<a href="http://Contact.com">anchored text</a>{% endblock %}
</body>
</html>
3 Answers
Chris Freeman
Treehouse Moderator 68,457 PointsHey Danielle Murray, you are not far off.
From index.html, blocks of code are used to replaced the corresponding block in the extend template, in this case, layout.html. Any named block layout.html that is also in index.html will be replaced with the index.html content.
So to replace the `{% block link %}{% endblock %} in layout.html, you need the same tags in index.html. In between these tags in index.html add the desired link.
Note the href=""
location should not contain text, and the anchored text, in this case Contact, goes between the HTML tags <a href="">
and </a>
.
In tasks 1 and 2, the file layout.html does not need to be altered.
Post back if you need more help. Good luck!
Danielle Murray
Python Development Techdegree Graduate 7,755 PointsChris Freeman This is my revised code:-
{% extends "layout.html" %}
<a>href="">Contact</a>
{% block link %}{% endblock %}
But it still doesn't pass
[MOD: added ```python formatting -cf]
Chris Freeman
Treehouse Moderator 68,457 PointsVery close! All the bits are there. The line order is incorrect: it should be:
{% extends ...
{% block link...
<a>href=“”...
{% endblock ...
(sorry, partial lines used to prevent cut-and-paste use)
Danielle Murray
Python Development Techdegree Graduate 7,755 PointsChris Freeman This is my revised code:-
{% extends "layout.html" %} <a>href="">Contact</a> {% block link %}{% endblock %}
But it still doesn't pass
Chris Freeman
Treehouse Moderator 68,457 PointsChris Freeman
Treehouse Moderator 68,457 PointsAlso note, the challenge checker expects the template tags
{% %}
within index.html to be on separate lines.I've flagged this as a bug, but it might be a while before it is fixed.
Danielle Murray
Python Development Techdegree Graduate 7,755 PointsDanielle Murray
Python Development Techdegree Graduate 7,755 PointsHi Chris Freeman I changed my code to:-
and I left layout.html as is put it still is not passing, what is my mistake?
Chris Freeman
Treehouse Moderator 68,457 PointsChris Freeman
Treehouse Moderator 68,457 PointsThe checker for this challenge is very picky. Your code is correct for Task 2, but the checker wants:
href=""
{% block link %}
and{% endblock %}
tags needs to be on their own separate lines. That is, there should be four lines of code including theextends
line.