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 trialEthan Chae
18,747 PointsAdd current_user Check, Build a Social Network with Flask
I don't think I understood how to create menus with links to these pages. Can anyone explain me what is the issue with this code?
<!doctype html>
<html>
<head>
<title>Lunch</title>
</head>
<body>
<nav>
{% if current_user.is_authenticated %}
<a href="{{ url_for('logout') }}" class="icon-power" title="Log out"></a>
{% else %}
<a href="{{ url_for('login) }}" class="icon-power" title="Sign In"></a>
<a href="{{ url_for('register') }}" class="icon-power" title="Sign Up"></a>
{% endif %}
<!-- Add menu here -->
</nav>
<div class="messages">
{% with messages = get_flashed_messages() %}
{% for message in messages %}
<div>{{ message }}</div>
{% endfor %}
{% endwith %}
</div>
{% block content %}{% endblock %}
</body>
</html>
3 Answers
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsThe words "Sign Out", "Sign In", "Sign Up" should go in between the opening and closing anchor tags. These are the words that will appear on the screen and will be linked to the view. You were also missing a closing quote marking for 'login'.
<nav>
{% if current_user.is_authenticated %}
<a href="{{ url_for('logout') }}" class="icon-power">Sign Out</a>
{% else %}
<a href="{{ url_for('login') }}" class="icon-power">Sign In</a>
<a href="{{ url_for('register') }}" class="icon-power">Sign Up</a>
{% endif %}
</nav>
Chris Freeman
Treehouse Moderator 68,441 PointsYou are very close. Two typos and syntax issue:
{% if current_user.is_authenticated() %} {# <-- add missing parens #}
<a href="{{ url_for('logout') }}" class="icon-power" title="Log out"></a> {# <-- Change to 'Sign Out' #}
{% else %}
<a href="{{ url_for('login') }}" class="icon-power" title="Sign In"></a> {# <-- add missing quote after login #}
<a href="{{ url_for('register') }}" class="icon-power" title="Sign Up"></a>
{% endif %}
Like the formatting here? Surround your code block with ```html+jinja and ```
Ethan Chae
18,747 PointsGuys, both of you were really helpful! Thank you so much. I was stuck on this bit for a while. Couldn't really move on :)
Chris Freeman
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 PointsBrendan, you are on fire! Keep up the good work!
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsBrendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsI'm glad my flawed answer is of some use :)