Space Cadets
Star Map


Astro Lesson #16 : its.all.relative.or.down.the.cyberpath

Venturing into the big wide world of HTML and webpagery is fun and exciting! When starting out, it's enough trying to figure out how all this stuff works, without having to be overly tidy and organised at the same time. However, once you get the hang of everything, and ye little 'ol web page has expanded beyond your wildest dreams, things gotta change - for the better.

All those HTML and image files lumped in together. Well - they got along okay in the beginning, but now that things are moving on up, it's becoming difficult to find just the right file without having to scroll and fossick, as they jostle with each other. Let's do a tidy up exercise - we know housework is hateful, but think how professional the resulting source code will look.

And it's a good thing to look back over our early work to see what can be improved - check that spelling, tidy that code, toss out that annoying animated gif that takes 2 minutes to download - it's great, but it's just too BIG.

helpful.housework.hints
Firstly, have a look at these files and decide on a hierarchical structure - that means, check out the kind of files you have hidden away and start making some folders (directories) to pop them into to.

For instance, we at retrocity like to have our HTML files at our fingertips - as these are the ones we are most likely to change - most often. After them, we have all our image files - jpegs and gifs. So we created a directory called 'pics' (we like to keep things plain round here!). That's probably all we have to do for a simple homepage, but sometimes life gets complicated.

Take this site for example - If you take a few minutes to explore, it's obvious that there is quite a bit of information involved, some of which changes on a monthly basis. Trying to figure out which files to remove and which to keep can get quite confusing if no structure is adhered to.

In this example, we have plonked all the stuff into places where it is easy to get at, and easy to manipulate. We have a 'pics' directory, then within that seperate directories for authors, photos, buttons, and more.

down.the.cyber.path
Righty-Ho!. That's that taken care of - but "wait" we hear you say! - How do we not end up with great, huge long path names in our links? Okay, let's then talk about relative and absolute paths.

absolutely.fabulous
We know how to insert a link to another page, don't we? Like so ...

<a href="http://www.users.bigpond.com/retrographix/nebula.html">

Translation = Go to the bigpond place (using http good manners), find the room called retro, and look in there for an html document called nebula. Cool.

This is called an ABSOLUTE path, because it can be found from absolutely anywhere - a bit like giving directions to Cousin Ned's Ferret farm in New Zealand, from somewhere outside that country. "First, you gotta get to New Zealand, then travel to the North Island, then find the town of Rotarua - take a right at the last mudpool, and voila ! Ferret's galore ..."

getting.on.with.the.relatives
Now, if a person was already in Rotarua, they would think you more than a little odd if you gave directions starting with how to get to New Zealand. They want to know the shortest route from where they are standing right here and now - "Turn right at the last mudpool. Ah, Ferret heaven!"

How do we translate this within a web page? Easy peasy ...
<a href="brain.html">

Cos we are already at http://www.users.bigpond.com/retrographix. This is called a RELATIVE path, because it relates to the point we start from.

What then happens to all the files within seperate directories if we decide use relative pathnames? - no problemo. Say we have a nice photo of Cousin Ned's prize ferret in a directory within our homepage files, pics/photos/ferrets.

<img src="pics/photos/ferrets/nedsprize.jpg">

the longwinded absolute version would be

<img src="http://www.users.bigpond.com/retrographix/pics/photos/ferrets/nedsprize.jpg">
which hardly fits on one line - stinky!

Relatively Absolute
Don't forget : we do this with images because web pages are not like ordinary wordprocessing documents. In their case, pictures and graphics are embedded - or permanently stuck alongside the text. As for web pages, browsers can't 'see' images until we point them to the right address - the piccys are not embedded, in fact they are separate. Like a piece of a puzzle.

Make sure you check out all the links and images before uploading via ftp to the net - a little detective work now can save headaches later on - and ensures that visitors to your site see what you intended, and not a bunch of blank spaces - or file not found errors.

Of course, the beauty of using RELATIVE addresses is that this testing can be done right on your own computer - you don't need to wait until everything is uploaded. Remember - the browser looks for links relative, or near to, where it already is pointing to.

It's also much easier to manage if changing providers - say we went from our provider (bigpond.com) to another (smurf.net). If we had been using ABSOLUTE pathnames, we would be forced to track down each and every link and change the reference from bigpond.com to smurf.net - tiresome and tedious. Instead, we don't have to do much at all - the relative links are found from where we move to.

Ah, so much to learn. So little time

Well, that WAS exciting, wasn't it children? Now run along and worry over these whisperings. Until next time when we think of something else to waffle on about.
next.pod
copyright.wendy.phillips.1998-2000

 


(The Retro City neurometer is reading that your brain is now full)
Remember, Space Cadets! This is a basic guide only - go read the manual.

back.to.space.cadets.lounge
Space Cadets

retro city