a jaundiced eye: stuck
for tuesday, april 1, 1997. Relatively Poor HTML
As part of my ongoing crusade against bad HTML, I'd like to take some time to congratulate the folks who are using relative links in their handcrafted HTML. It's certainly a step towards portability. Not using absolute links such as
<a href="http://www.myserver.com/somefile.html"> gives you a better chance to move your site around from one server to another without having to learn extensive search and replace strings in your editor.
The problem is, many webmasters and content providers use relative links containing ".." to link back to pages in directories above the current page. This presents a problem when you want to move your content around a bit - not only do you have to worry about where your files are, you have to worry about where they were, and how other files are hardcoded to link to their former locations.
A better way to handle this, if you have some control over your server or at least know where your files are relative to the server root, is to use top-down relative links. An example is <a href="/mysite/fish/trout.html">. Combined with the sane use of server aliasing (or, as it is known in the PC world, Virtual Directories) you come close to the Handcoder's Nirvana. By defining your site(s) in terms of categories such as "/fish/" above, you can then put as many files related to that category as you want. By using Aliasing or VDs, you can even redefine the location of the whole group of files in seconds. You can also use symbolic links, if your server config is out of your hands.
The other benefit is that you don't have to type as much - important for those space-constrained instances such as business cards, where it is simply inconvenient to tack "index.html" onto the end of your URL. But I'm getting off track. The use of default filenames is a topic for another article.
For example, I have a fun Java applet that implements Chernoff Faces. When I first published the files related to the applet, I put them in the "Faces" subdirectory of my site, http://www.hesketh.com/schampeo/. Later, however, I found that I wanted to put the whole shebang under a directory named "projects" for sake of organization. On the server in question, I don't have control of the config, so I used a symlink to provide backwards compatibility to anyone who might be looking for the applet and its doumentation. If I were more in control of the site I would have used Aliases, but in this instance I could not.
Its a good thing I put the symlink there, because the good folks at Gamelan published a dead-tree edition of their directory, and my Chernoff Faces applet got included. I even got a screen shot ;^) So when the world flocked to see my kewl applet, they weren't greeted with a 404 - Not Found error. Instead, they got to see my applet in all its first-attempt-at-Java glory.
The thing to take from this episode is that if you treat your files like individual nodes in a huge network, and make the foolish assumption that the network is static, you will be in trouble down the line. Better to treat your files as parts of larger collections, and put those files in directories carefully named to reflect your organizational structure.
© 1997-2001
Steven Champeon. All rights reserved. |