Improve Site Performance Increase Site Traffic Monitor Site Uptime Webmaster Resources NetMechanic Home Looking For Help? Partner Programs Privacy Policy Contact Us Press Room
NetMechanic Home LOGIN | HELP | ABOUT US | PRODUCTS | SITE MAP
NetMechanic Menu
Over 52 Million Web Pages Tested!     
 

Search for:


Your Email:

I would like to receive my newsletter in:
HTML format
Text format



Volume 8 (2005)
   September
   June
   April
   March
   January

Volume 7 (2004)
   November
   September
   July
   June
   May
   April
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 6 (2003)
   December
   November (Part 2)
   November
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June (Part 2)
   June
   May (Part 2)
   May
   April (Part 2)
   April
   March (Part 2)
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 5 (2002)
   December (Part 2)
   December
   November (Part 2)
   November
   October (Part 2)
   October
   September (Part 2)
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June (Part2)
   June
   May (Part 2)
   May
   April (Part 2)
   April
   March (Part 2)
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 4 (2001)
   December (Part 2)
   December
   November (Part 2)
   November
   October (Part 2)
   October
   September (Part 2)
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June (Part 2)
   June
   May (Part 2)
   May
   April (Part 2)
   April
   March (Part 2)
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 3 (2000)
   December (Part 2)
   December
   November (Part 2)
   November
   October (Part 2)
   October
   September (Part 2)
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June
   May
   April
   March
   February
   January

Volume 2 (1999)
   December
   November
   October
   September
   July
   June
   May
   April
   March
   February
   January

Volume 1 (1998)
   December
   November
   October
   September

 

Beginner Tip:
Let Your Server Fill In The Blanks

by Larisa Thomason,
Senior Web Analyst,
NetMechanic, Inc.

  
January 2001
(Part 2)
Vol. 4, No. 2
 • Promotion Tip
 • Design Tip
 • Beginner Tip
  

Apply the "Less Is More" principle to your internal page links using relative URL addresses. They can simplify your Web site administration tasks. Relative URL's help you avoid broken links, minimize spelling errors, easily move directories to a new server, and change directory names without breaking links.

Relative vs. Absolute URL's

An absolute URL is like your full, legal name while a relative URL resembles the nickname your friends and family use. You legal name might be William Albert Jefferson, but your friends and family call you Bill. Both names refer to you accurately, but are used in different contexts.

The same principle applies to relative and absolute URL's.

An absolute URL completely and unambiguously defines the location of a Web page. An absolute URL will work on any page in your site - or anyone else's. An absolute URL looks like this:

http://www.SiteURL.com/files/January/1_10Story.htm

That's all the information any server needs to locate the proper page.

Let's look at the individual components:

  • http:// = the protocol type
  • www.SiteURL.com/ = the host name
  • files/January/ = the directory path
  • 1_10Story.htm = the individual file name

A relative URL is merely an absolute URL with some information left out. When you click on a relative link on a page, the Web server resolves the address by filling in the blanks with the current page's information.

A relative URL is usually much simpler to read and type. For instance, a relative URL to another story in this newsletter issue could be as simple as <a href="promo_no2.htm"> because it refers to a file in the same directory as this page.

Writing A Relative URL

The term "directory" confuses many beginning webmasters. It may be less confusing at first to think of them as folders instead. You can organize your Web site just like you might group together related Word or WordPerfect documents on your personal computer.

Relative URL's are easiest if you're referring to a file in the same folder as the referring file (the file that contains the link) file, but you can use relative URL's for any file location in your site - as long as the files all reside on the same server.

Let's look at a sample Web site structure:

sample Web site structure


Assume for the examples below that the current file is:
http://www.siteURL.com/files/January/1_10Story.htm

  • Refer to another file in the "January" folder:
    <a href="1_11Story.htm">
    This tells the server to look in the same folder as your referring file.
  • Refer to a file called "news" in the top-level folder:
    <a href="../../news.htm">
    Here, the server looks up two levels in the folder structure (from January to files, then from files to the top level). Indicate this using the UNIX file addressing system of one "../" for each level.
  • Refer to a file in the "March" folder:
    <a href="../March/3_1Story.htm">
    The server will look up one level to the "files" folder and then look for the "March" subdirectory. You could also refer to this file as <a href="files/March/3_1Story.htm">, but if you ever change the name of the "files" folder, the link will break.
  • Refer to a file called "calendar.jpg" in the "Images" subfolder:
    <a href="Images/calendar.jpg">
    This tells the server to go down a level from the current folder to find the file.

This seems complicated, but it really isn't. All you need to do is tell the server how to find the news file in relation to the current file. It's like providing landmarks when you give someone directions on how to get to your house.

Make Moving Simple

Many developers do their initial design work offline on their own PC's before uploading the pages to a server. But remember that files on your PC will have a completely different address than pages on the server. An absolute address for a page on your own PC might be:

file:///C:/Home/OtherPages/MyOtherPage.html

You don't want to refer it that way on your page though, because the links will break when you upload the file. Instead, use a relative URL address so the link will still work after you upload the folder to the server.

sample folder structure


Use a relative address to link MyOtherPage.html to HomePage.html and you won't have any problems when you move the files.

Change Names Without Changing Code

If your Web site contains more than a few pages, you've probably found that it's much easier to administer if the files are organized into separate folders. Use relative URL's to make site administration even simpler.

For instance, you might have all your images in an "Images" folder, newsletter issues in a "Newsletters" folder, etc. This structure works great, but then you need to change a folder name. What happens to your links?

Nothing, if you've used relative URL's.

For instance, in a previous example, we have a folder named "files." But suppose that, as the site grows in complexity, we need something more specific like "MonthlyNewsStories"? Since the URL links are relative, we could change the folder name without affecting any links. If we had used absolute addresses, every link would have to be updated when we changed the name of the "files" folder.

Think of the time involved, not to mention the potential for errors!

Check Links Automatically

Of course, no matter how careful you are, you still need to check your all links regularly to make sure they work. With internal links, you may make changes in a hurry and not think to test the impact of the changes on every link. External links can be even harder to monitor since you have no control over how other webmasters maintain their sites.

NetMechanic's HTML Toolbox includes a feature that tests the links on your pages and alerts you to broken links. We also make it easy to do regular testing, with our free monthly tune-up service.



Rate This Tip:
Not Useful Useful Very Useful   
 
NetMechanic Tools
HTML Toolbox
Browser Photo
Server Check
Search Engine Starter
Search Engine Tools
GIFBot
Newsletter
HTML Tutorial and Tips
Search Engine Tutorial
Accessibility Information
Browser Problem Tutorial

Company Info
Products
About Us
Contact
Advertise
Link To Us
Jobs
Privacy Policy
Partner Programs
Press Room
RSS Feed
Support
 



Powered by Overture!

 
     
 
   
 
     


Keynote Home
Copyright © 1996-2007,
Keynote NetMechanic
All rights reserved.