Don't you just hate it when "index.html" appears in the page
location when you're exploring your own web site?
Most people now know that although their home page is
called something like index.html,
they can get to and advertise the home page by using the
web address www.site.com. It's
(thankfully) quite rare that web site addresses are
advertised as www.site.com/index.html.
If you go to a site using www.site.com and then click back to the home page, the page location is
often shown as www.site.com/index.html.
There is a very simple way to stop this from happening on
your own sites.
I've listed the HREFs to use to link to
the home page or to other default pages in directories so
that index.html won't appear in the page location.
The first list describes
relative links, the next absolute.
- Home page (same directory)
- If you want to link to the home page from another
web page in the same directory, use the HREF "./" (dot slash)
Use this method to make a link to the default page
within any directory. For example, a directory called
articles may include individual articles and a
page listing all the articles.
It makes most sense for the default page name, e.g.,
index.html, to be used for the article index.
Each article will likely include a link back to the index
(that is, the default page in the same directory).
Use the HREF "./" to create the link to the
article index from each article.
I know that the "./" HREF works on
Unix and Linux web servers. I haven't tried it out on
PC-based web servers.
- Home page (relative)
- If you can't use absolute HREFs and the home page is a level
up from the current web page, use the HREF
"../" - if two levels away, use
Each "../" means "go up a
directory". The downside of this approach is having to
change all the relative links if a web page is moved up
or down in the file system.
- Directory below (relative)
- To link to the default page of a directory below the
current position, use the HREF "articles/" (no
slash at the beginning).
- Directory above (relative)
- To link to the default page of a directory above the
current position, for instance if the current web page is
in a sub-directory archive of our example articles
directory, use the HREF "../"
An example of a web site which uses relative links in this
way is my personal
Alternatively, if the home page of your
live web site is in the root directory, use absolute links.
- Home page (absolute)>
- Use the HREF "/"
- Directory (absolute)
- To make a link to the default page in a directory, for
example www.site.com/articles/, use the HREF
(and use "/articles/archive/" for the
The advantage of absolute links is that you use the same
HREFs to link to specific pages regardless of where on the
web site the pages are which include those links.
The disadvantage of absolute HREFs is when your local
development copy of the web site isn't in the root directory.
Using links then becomes impossible.