You should also know about relative and absolute links. When linking
from your site to another site, always use absolute URLs, which means the
whole kit and caboodle: http://www.invalid-domain.co.uk/. This way tells the
browser to leave whatever server it's currently on and go over to the invalid-domain server to look for the Webmonkey
directory. But when you're linking to another file on your site, you might
be better off using a relative link.
"Relative" means you don't include the whole URL; you just define the
file you're linking to by its relative position to the current file. So if
you're working on links.html in a
directory called current, for example,
and you want to link to a file called news.html that's in the same directory, you can use a
relative link. So instead of:
<a
href="http://www.invalid-domain.co.uk/current/news.html">
... you would use:
<a href="news.html">
There are several advantages to using this method, aside from saving
yourself a good chunk of typing. First, it makes life easier for the
browser. When you give it the entire URL, it goes back to the root level
(in the above example, that would be the invalid-domain server) and digs through all of the folders to
locate news.html. Although it really
doesn't take all that long, those little delays can add up, making the user
wait and the browser do unnecessary work.
More important, relative URLs mean that you could take your entire site
and move it to a new server, and all of the links would still work. Since
you aren't including the http://www.invalid-domain.co.uk/ stuff in the link, it doesn't matter
if it suddenly changes to http://www.main.invalid-domain.co.uk/. This means your site is much more
flexible, and you won't have to go into every single page and change every
single link if the server changes.
What if you're using a relative link, but the file you're linking to is
in another directory? All you need to remember is one cryptic Unix command
that looks like this:
../
This command tells the browser to get out of the directory that it's
currently in and to go to the parent directory (i.e., the folder that
contains the current folder). So let's say you're back in links.html in the current directory and you want to link to archive.html, which is in a directory called
old. Both old and current are in
the same folder, so you can use this relative link:
<a href="../old/archive.html">
This will get the browser out of the current directory (current) and into old, where it will locate archive.html. You can string together as many dot-dot-slashes
(../) as you need to get to the correct folder.
There is another option you might want to consider. If a link starts
with a slash (/), the browser will go immediately to the root-level folder
and start looking from there. For instance, to link from http://www.stapler-co.com/industrial/guns/plaster/silver/themonster.html to the company homepage (http://www.stapler-co.com/index.html), you
could use this simple link:
<a href="/index.html">
This way, there's no need to bother with all those dot-dot-slashes.
That's about all you need to know to set up a smart backend structure
for your site. Being thoughtful about the architecture won't guarantee
relentless traffic, but it will help you build a site that's both easy to
maintain and easy to navigate two very handy attributes.