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 trialNicholas Dirks
2,442 PointsMy nav block in my article.html is not linking to the about, articles, or contact links. My code is below.
<nav>
<ul>
<li><a href="../../index.html">Home</a></li>
<li><a href="../../index.html#about">About</a></li>
<li><a href="../../index.html#articles">Articles</a></li>
<li><a href="../../index.html#contact">Contact</a></li>
</ul>
</nav>
3 Answers
David Perkins
9,607 PointsI've laid your code out below in a more legible way so that we can discuss it better if needs be.
The error that you're getting suggests that you're linking to a file that doesn't exist. Each time you're prepending the filename with ../
you're basically saying go back (or up) one directory level in your structure.
<nav>
<ul>
<li><a href="../../index.html">Home</a></li>
<li><a href="../../index.html#about">About</a></li>
<li><a href="../../index.html#articles">Articles</a></li>
<li><a href="../../index.html#contact">Contact</a></li>
</ul>
</nav>
So to answer your question, if you're getting the "The requested URL /index.html was not found on this server." error, that suggests that your index.html file isn't 2 directory levels back (or up) from the file that contains this code. To fix, if the index.html is in the root, remove the 2 ../
paths and go for a single /
instead. If it's only 1 directory level different, just remove one.
<nav>
<ul>
<!-- If the index.html file is in the root, try this -->
<li><a href="/index.html">Home</a></li>
<!-- If it's only one directory level back, try this -->
<li><a href="../index.html#about">About</a></li>
<!-- If it's in the same directory level as this file, try this -->
<li><a href="index.html#articles">Articles</a></li>
<!-- If it's 3 levels back in the structure, try this -->
<li><a href="../../../index.html#contact">Contact</a></li>
</ul>
</nav>
Hope this helps but if you need more advice or help, let me know and i'll be happy to explain better and/or have a look further into the issue you're having.
Nicholas Dirks
2,442 PointsIt won't let me edit my question but the error I am getting is below.
The requested URL /index.html was not found on this server.
Nicholas Dirks
2,442 PointsThank you for responding so fast!! So I tried the examples that you laid out and my folder layout is (Folder) articles-->2017-->article.html so I would assume it would be ../../index.html? For some reason it keeps coming back with not found. My index.html is in the main(root?) folder. All of my other links going to my article.html file work seamlessly but its just going backwards which is causing me problems on all my links.
Thank you again for helping!!
David Perkins
9,607 PointsNo worries 🙌🏻
If the structure is "root/articles/2017/article.html", and your index.html file is definitely named "index.html" and is definitely in the root folder, that would make the path from article.html -> "../../../" as you're going back/up three levels.
If adding another "../" doesn't sort it, can you screenshot your directory structure or print a tree so that I can try and diagnose it further?