How can I link to html pages if they are in same or different folders without writing full path?
use the relative path
main page might be: /index.html
secondary page: /otherFolder/otherpage.html
link would be like so:
<a href="/otherFolder/otherpage.html">otherpage</a>
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>
Within the same folder, just use the file name:
<a href="thefile.html">my link</a>
Within a super-directory:
<a href="../thefile.html">my link</a>
Within a sub-directory:
<a href="subdir/thefile.html">my 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.
I would caution you: if you are using absolute paths, then your application cannot be installed in a "subdirectory" of the server!
eg, http://yourserver.com/yourapp may work, but http://myserver.com/apps/yourapp will not!
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>