Links to Pages on Your Site

When you’re referring to pages on your own site, you should always use relative URLs rather than absolute ones. Let’s presume that you are the owner of the website at, and its files are laid out in the structure that you see at the right.

If you wanted to put a link to the survey.html file inside the index.html file, you’d use a relative pathname to the destination href.

See the
<a href="sales/survey.html">sales survey</a>

Similarly, a link in the file summary.html back to index.html would look like this:

<a href="../../index.html">Main Index</a>
Graphic of nested files
Graphic of moved file structure

Because we have used relative pathnames for these hrefs, our links will continue to work even if all of our files (outlined in red) are moved to a sub-directory of a new server, as shown at the left. If we had used absolute pathnames, we’d have had to re-write all of the links.

<< Other Outside Links Index Within-page links >>