Virtual Mechanics

Relative Paths

If you are an IMS user you are no doubt familiar with the Gather
option in the IMS Publisher. This feature can substantially simplify
the process of composing a web page by allowing you to select an
image file anywhere on your computer and then have the Publisher
'ftp' or 'copy' it to the output directory. In addition to automatically
transferring the file, the Publisher will also update the file path in all
the exported HTML files so that they point to the new location of the
image. The Gather option will consequently greatly minimize the
occurrence of missing images on you web site. So why would you
not want to use it?

The 'File Path' dialog in the Publisher includes a 'Relative File Path'
option in addition to the Gather Option. What is a 'Relative File
Path' and when should you use it?

If you are new to developing Web Sites or have a relatively small
site (under 10 pages?), then the Gather Option is your safest and
simplest method of ensuring that things go right. If you are
developing a large web site with multiple directories, then using the
'Relative File Path' may be advantageous.

The difference between the 'Relative' and 'Gather' options is on the
surface quite simple. Since the Gather Option copies all of its image
files to the same directory as the exported HTML file, the "img" tags
can simply point directly to the filename. Since the Relative option
does not copy the image file, it's path must be constructed relative to
the location of the HTML file.

For example, if the image "mypic.gif" is located in a subdirectory
called "/pics" the Gather option would copy the file to the parent
directory and produce an image tag: <img src="mypic.gif">. The
relative Option on the other hand, will not copy the image but will
produce the following tag <img src="pics/mypic.gif">. For this
second option to work, you must mirror the directories and files on
your server that are also located on your development machine.

There are several advantages to using Relative file paths. First, you
can create subdirectories to group common files together. We use
numerous subdirectories on our site for things such as the
IMSWebTips news letter, for our on-line Store and for our Support
pages. We also have several different URL's parked in subdirectories
for the main site. If we used the Gather Option, we would have to
duplicate all the common elements in each subdirectory or we would
be forced to maintain one huge directory that would be very difficult
to manage.

Another advantage to grouping files in subdirectories is the ability to
make a change to a single file and know that it will be updated
throughout the entire site. For example, the Virtual Mechanics site
uses four small GIFs for its common page design elements. These
are bright tropical yellow and peach shades no doubt selected
because we spend too much time working in South Florida. If we
want to reflect the change of seasons in the north by selecting cooler
more subdued colors, we could simply replace these four files and
know that the change would be made throughout the entire site.

If you develop your web site offline, you will need to duplicate your
web site on your Development machine, directory for directory, in
order to use the Relative Option. Since the Relative option also does
not copy any Image or Audio files to the web server, you will need to
transfer these files separately. Extra testing will also be needed to
ensure that everything is working correctly. Also note that the
Relative option will not let your reference files across different drive
letters on your development machine since this can not be
reproduced with a relative file path.

As an aside, you will also notice that the 'File Path' dialog will make
an 'Absolute File Path' option available when you select the Export
to Disk option. The Absolute option will insert the full directory
path of an image including the disk drive letter, into the output
HTML file. The only advantage to this option is if you are
developing your web site directly on your server and wish to locate
image files on other disk drives. Using the Absolute File Path option
is consequently not suitable for Publishing your HTML projects to a
different computer.

To sum up, if you have a relatively simple web site or are not
experienced with managing a web site, use the Gather option when
publishing your projects. You can always try the 'Relative' option at
a later time. If you are developing a large web site, consider using
the 'Relative Option', to speed transfer times, minimize disk usage,
optimize downloads and give yourself more site management

"IMS Web Tips" ISSN 1488-7088
© Copyright 1999 Virtual Mechanics

"IMS Web Tips" is a weekly news letter for all web site managers regardless of experience who are looking for detailed information on
creating, maintaining and promoting their web sites.

To subscribe send an email to tips@imswebtips.com with SUBSCRIBE
as your subject or visit the IMS Web Tips home page for subscription information and a list of past articles.
Click here for a free WYSIWYG pixel precision HTML editor.
For the best in D HTML editors
Archive by Date
Archive by Topic
IMS WebTips