Benjamin Lu

everyday is cool

Keeping Relative Links Working

Written retrospectively for the 2003 archive.

A small site is easy to move until the first link points back to a folder on your own computer. To see how portable links work, make an index.html file and put an About page in pages/about.html.

From the homepage, link to pages/about.html. From the About page, link back to ../index.html. The two dots tell the browser to go up one directory before looking for the file.

Copy the whole folder to a different location and open both pages again. The links should still work. As a final test, move the About page one level deeper and see which links need updating. It’s a small exercise, but it explains a lot of broken links on hand-built sites.