How to link html pages in same or different folders?
Within the same folder, just use the file name:
<a href="thefile.html">my link</a>
Within the parent folder's directory:
<a href="../thefile.html">my link</a>
Within a sub-directory:
<a href="subdir/thefile.html">my link</a>
Read more... Read less...
Also, this will go up a directory and then back down to another subfolder.
<a href = "../subfolder/page.html">link</a>
To go up multiple directories you can do this.
<a href = "../../page.html">link</a>
To go the root, I use this
<a href = "~/page.html">link</a>
In addition, if you want to refer to the root directory, you can use:
Which will refer to the root. So, let's say we're in a file that's nested within a few levels of folders and you want to go back to the main index.html:
<a href="/index.html">My Index Page</a>
Robert is spot-on with further relative path explanations.
You can go up a folder in the hierarchy by using
So to get to folder /webroot/site/pages/folder2/mypage.htm from /webroot/site/pages/folder1/myotherpage.htm your link would look like this:
<a href="../folder2/mypage.htm">Link to My Page</a>
use the relative path
main page might be: /index.html
secondary page: /otherFolder/otherpage.html
link would be like so:
If you'd like to link to the root directory you can use
If you'd like to link to a file in the same directory, simply put the file name
<a href="/employees.html">Employees Click Here</a>
To move back a folder, you can use
To link to the index page in the employees directory from the root directory, you'd do this
<a href="../employees/index.html">Employees Directory Index Page</a>