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

HTML

Miriam Allman
PLUS
Miriam Allman
Courses Plus Student 1,761 Points

why does my code in article.html not take me back to index.html?

Here is my code

<nav>
    <ul>
        <li><a href="../index.html">Home</a></li>
        <li><a  href="#">About</a></li>
        <li><a  href="#">Articles</a></li>
        <li><a  href="#">Contact</a></li>
     </ul>
     </nav> 
 </header>

 <article>
     <header>
        <p>By: Nick Pettit</p>
        <p>Published: June 19, 2017</p>
         </header>
michaelcodes
michaelcodes
5,604 Points

Hi there! Could you please specify the video or challenge this is for? or a snapshot would be really good. If not, or if it is a non-related project the file paths/tree

Hi Miriam.

I'm just wondering. Your "index.html" file seems to have a separate file path to the rest of your .html files.

Does it work when removing the " ../ " from the index.html file path ?

Miriam Allman
Miriam Allman
Courses Plus Student 1,761 Points

I just tried changing the file path by removing the .../ but I when i click on Home to take me back to the home page - I get a message file not found

Steven Parker
Steven Parker
231,124 Points

To facilitate analysis, make a snapshot of your workspace and post the link to it here.

4 Answers

Matthew Lang
Matthew Lang
13,483 Points

Please make sure your folder structure is similar to this.

project
│   index.html

└───folder1
│   │   article.html
Steven Parker
Steven Parker
231,124 Points

It does seem unlikely that the HTML files would be located in different directories. Perhaps the link back to index.html should be:

  <li><a href="index.html">Home</a></li>

If that's not it, please make a snapshot of your workspace and post the link to it here.

Miriam Allman
PLUS
Miriam Allman
Courses Plus Student 1,761 Points

I am using text editor on a mac - here is the entire code

<!DOCTYPE html>
<html>
  <head>
  </head>
    <title>VR Article</title>   

  <body>
      <div>
      <header>
    <h1>Experience VR</h1>
    <p>A simple blog about virtual reality experiences </p> 


    <nav>
    <ul>
        <li><a href="index.html">Home</a></li>
        <li><a  href="#">About</a></li>
        <li><a  href="#">Articles</a></li>
        <li><a  href="#">Contact</a></li>
     </ul>
     </nav> 
 </header>

 <article>
     <header>
        <p>By: Nick Pettit</p>
        <p>Published: June 19, 2017</p>
         </header>

         <img src="../../img/vr-user.jpg"  alt="User trying a VT headset">
   <h2>VR Article</h2>
   <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce finibus urna lacus, ut lacinia elit pretium a. Praesent rutrum ac ipsum vitae rhoncus. Nam non molestie purus.</p>
   <aside>
    <q>This is a pull quote from the VR article...</q>   
   </aside>
   <p>Nunc imperdiet, dui in varius eleifend, magna enim imperdiet felis, at ultricies magna metus vitae ante. Nulla in porttitor nibh. Mauris non libero in massa porta varius non sed magna. Donec ac mauris mattis, viverra turpis ac, dictum arcu.</p>
   <p>Vivamus molestie laoreet viverra. Ut ac fringilla ex. Donec at nisl semper, commodo mi maximus, fermentum nisi. Duis bibendum gravida ante sit amet consectetur. Curabitur ac est id justo eusimod porta quis ac arcu. </p>
 </article>


 <aside>
     <h3>More Articles About VR</h3>
     <ul>
        <li><a href="#">Make a VR Game</a><l/i>
        <li><a href="#">Learn VR in Unity</a><l/i> 
        <li><a href="#">Build User Interfaces in VR</a><l/i>     
    </ul>        
    </aside>


    <footer>
      <p>&copy;2017  Experience  VR, The Blog</p>

    </footer> 
    </div> 
   </body>

</html>
Steven Parker
Steven Parker
231,124 Points

This issue is about both the code and the environment, so the solution depends how the files are organized.

Also, when posting code, use the instructions for code formatting in the Markdown Cheatsheet pop-up below the "Add an Answer" area. :arrow_heading_down:   Or watch this video on code formatting.

Miriam Allman
PLUS
Miriam Allman
Courses Plus Student 1,761 Points

Thanks Steven,

I got it - the files was two levels up - as soon as I added a second ../ the pages linked perfectly.

Miriam

Hi Miriam.

Apologies to you. That was what I was trying to explain as that may of been your problem - your html files were not on the same file path as each other.

I usually create a folder for images, a folder for css files and leave all my html files in the root folder.

How do you paste a snap shot of the code on to here. I use Sublime Text on both windows and Mac but I can not copy paste to here. I wanted to show my Root folder file system. Just to see if helps in the future.