Carnegie Mellon University Website Home Page
 

Using Absolute and Relative References

Using Absolute References

An Absolute Reference provides the complete http address in the form of a full URL, including the server name and complete path. For instance, if you had a file named "foo.gif" in a subdirectory in your Andrew/AFS file area under your www directory named "images" (for Jane Doe, a directory ~jdoe1/www/images), you would link to it as an absolute reference as follows:

http://www.andrew.cmu.edu/user/jdoe1/images/foo.gif

Using Relative References

A Relative Reference provides a partial http address in the form of a fragment of a full directory path. Keep in mind that by default, if no server name or path is specified in html, the file reference is to the default current directory. If you are publishing files on the user web, the default would be any file within your www directory.

To use the example above, in relative references, Jane would specify the link as

/images/foo.gif

In html context, this might appear as:

<IMG ALIGN=bottom src="/images/foo.gif">

Advantages / Disadvantages of Using Absolute / Relative References

  • Using absolute references or links is NOT advised for those who:
    • publish on www.cmu.edu using the Andrew Web Publishing System (AWPS) and use the staging server to review content before publication: By changing your files to absolute references, you would lose the ability to easily click on those files on the staging server since the browser will be directed to the production server. Use relative references in this situation.
  • Using absolute references or links IS advised for those who:
    • publish on www.cmu.edu using the Andrew Web Publishing System (AWPS) and run the link check report on the staging server to review content before publication: By using absolute references you enable the report to check for linked pages that reside outside of the staging server. The result is a more accurate link check report. Also, when referring to a link in another AWPS collection, it is best to use an absolute link. That way you will preview their production content on the staging server while avoiding any issues with authenticating to this outside collection.
  • Absolute references will work only as long as the basic structure of your web pages and www directories do not change. So, if you move your Web pages to another directory, the reference would no longer point to the correct location. When using relative references, if you move your Web pages to another directory, the references to other files that were moved are still valid, so you don't have to change every reference.

Symbolic Links

Unix users may be accustomed to using symbolic (or hard) links to use a single physical file as a source for two or more filenames. For example, you might name your home page "jane.html" but want this to be the default page, so use a symbolic link in Unix to make "index.html" point to "jane.html".

For example, symbolic links are perfectly acceptable on the UserWeb server as long as they do not reference any file above your ~/www directory! This means if you symlink to a file that physically exists anywhere under your www directory, it will work. If, however, your html refers to a Symbolic (or hard) link to a file outside your ~/www directory, then it cannot be published. You will generate an error when this happens. Why? Many items that are "publically" available within AFS to Carnegie Mellon users are site- licensed, restricted, or otherwise considered to be for Carnegie Mellon users only. Further, there are some serious performance issues for the server if it could potentially list out all files in AFS. Consequently, the UserWeb Server does not allow linking of files that are not within the /www root directory.

Note: The same behavior for symbolic links holds true for OrgWeb, CourseWeb and AWPS content on www.cmu.edu as well.

If you need to make a link to a Project Volume, a friend's files, or other external AFS file, the simple solution is to have whoever owns that file publish it as an html file on either this server or any other web server, and use an absolute reference to access the document.

Last Updated: 4/23/05