Web File Basics

Module W50c

Audience and Objectives | About this document | Review

Contents

Organizing Files File Naming on the Web
Wherever you see this separator line in the document, clicking on it will return you to the Contents.

Organizing Files

Organization Issues



Organizing information is the most important task in getting a Web site set up, but there are a number of technical issues that impact site design as well. This module covers some of these issues:
  • Directory trees: a way of organizing information on computers
  • Relative URL References: how to link from one page to another within a Web site
  • The issue of tree "depth"
  • File naming
  • Where to put your images

Directory Trees



Here are the basics:
People store an incredible number of files on computer disks! In order to organize these so they're not all jumbled together, "folders" or "directories" can be set up to put files in logical places. All computers use a hierarchical "tree" pattern for saving files in directories. (It's called a tree, but the "root" is at the top, so it's a very upside-down tree!) 

Every disk has a "root directory" containing files and other directories. These subdirectories may contain other files and directories.

How does this apply to the Web?
The "root" directory for a Web server is the directory in which that server starts looking for files. It doesn't have to be the root of the disk itself. For example, the Washtenaw Community College Web "root" URL is at
www.wccnet.org
but the root directory of the Web is actually is
/home/httpd/html

As you have noticed, directories and subdirectories in URLs are separated by forward-slashes / 

In addition, the directory one level up can be represented by two dots .. and the current directory by a single dot . These can be used in creating links, as we'll see now...
 

Tree Depth: Deep vs. Broad



As you plan your Web site and it begins to grow, you need to decide if you want a "deep" directory tree or a "broad" one. 
  • A deep tree is one in which many of the directories contain other directories, which have directories of their own, and so on.Deep Directory Tree
  • A broad tree is one in which the top level directory has many subdirectories, but the second-level directories do not have many subdirectories.
Shallow Directory Tree

Each plan has its tradeoffs:

  • Deep trees let you set up a relatively small number of files per directory. Small directories are often easier to manage than large ones, but the URL gets longer the deeper you go.
  • Broad trees end up with fewer directories but more files in each directory. The URLs stay relatively short. But with large numbers of files in each directory, you, as the designer, need to use a systematic file naming pattern so you can find what you want easily.

Handling Images



In a simple Web site, the images are usually kept in the same directory as the HTML files. However, as Web sites grow, it becomes more difficult to keep track of the image files - especially if files from several directories want to refer to the same images. Many Web designers recommend creating a special image directory and putting all images there. 

I have found it generally simpler on my site to keep the images together with the files they are used with. This results in some duplication, but fewer directories. Oh well, it's yet another tradeoff!
 

On your Own Computer



In many organizations, one person is in charge of the Web site - or a specific part of it. Since you're reading this, let's assume that person is you! How should you get started with your Web site organization, and how should you maintain it once it's up and running?

A good, practical way to do this is on your own computer is called "mirroring":

Mirroring

  1. Create a subdirectory on your hard drive (or for a class, set aside a diskette) which will represent your Web site. A good name to use is public_html which is the name used on most servers.
  2. In your Web directory or diskette, create a file called index.htm. This will be your home page.
  3. If you want to keep images in a separate directory, create a directory called images to keep them in.
  4. If you need other subdirectories on your Web site, create them on your own disk as well. If you have many, you may find it useful to draw a diagram showing the relationships between them.
  5. When you are ready to put files on the Web, use your FTP program to create directories and subdirectories with exactly the same names as the ones on your disk - beginning at the level below your main Web directory. Then use the FTP program to transfer files from your disk to the Web server. (If you're using a service like CompuServe or AOL that doesn't give you access to the directory structure of your site, you'll have to keep it very simple: one directory for the whole site. Primitive, but it works as long as the site doesn't get too large!)
Your own files are now the "master" version of the Web site...be sure to back them up regularly! If anything goes wrong with the server, or if you need to move your site to another place, you'll have the latest files right where you need them - with you.

The advantage of using exactly the same directory names and file structures in both places is that you can create relative file links and have them work both on your own computer and on the server.
 


Naming Files for the Web

When you give your Web pages a file name, the name becomes part of the URL and so must be acceptable on many different kinds of computers. Here are the rules, sprinkled with a few guidelines:

The Home Page



The home page can have any of these names:
  • index.htm 
  • index.html
  • default.htm
  • default.html
What does "being a home page" mean?
A Web server is often given a URL with only a server name or a directory name, for example:
www.wccnet.org
www.wccnet.org/dept/cis/
The designers of the Web needed to give servers something to look for when this happens; so servers are programmed to look in the directory and give you any of these four files they can find. 

What if the server can't find any of these, but the directory exists? It's then programmed to give you a directory listing of the files in that directory; it's even linked so users can click on any listed file or directory and get it on their screen! But as a Web site designer, you will probably want to avoid giving your guests a directory list! It's rather like coming to an apartment building and finding a locked door with a row of labeled buttons to push. You hope someone is home! 

On the Web, it's much nicer to enter by a well-designed and attractive home page!
 

Spaces in File Names



No! Don't put spaces in your file names! Though some computers (Windows or Macintosh) allow spaces in file names, most Web servers are Unix-based. They let you store files with spaces in their names, but they don't find them when you look for them again!

When you use conversion utilities you may find that Web files are created with spaces in their names. For example, Microsoft Access has a utility to convert database tables and reports into Web files. This utility takes the names of Access tables, which can have spaces, and simply converts them into file names. This can cause lots of trouble if you're not cautious.
 

What Characters Can go in File Names?


You can use alpha characters (abcdefghijklmnopqrstuvwxyz), numeric characters (0123456789), the dash - and the underscore _ but avoid any other special characters.

Name Length



Keep your names under about ten characters in length. You can usually get away with more, but it's better to keep it simple, and the longer it gets the more likely a computer somewhere on the Internet will choke!

Case



Most (but not all) Web servers are case-sensitive - that is, they consider the letter Capital A to be completely different from the small letter a. A good rule to follow is, always use only lower case letters in Web file names. This is part of the "Keep It Simple" principle.

Caution: Capital letters can be a problem with MS Windows. Although Windows doesn't care about capitals vs. lowercase letters when it looks for files, it sometimes automatically capitalizes the first letter of a file's name when it saves the file for the first time! This can cause much frustration when you create links using lowercase letters. They work just fine when you test them on your Windows computer, but you find that on the server the links no longer work!

To avoid this problem, check the names of Web files and graphics on your computer using Windows Explorer or My Computer. If you find a file with a capital letter, click the name twice slowly to edit it, and change the capitals to lower case. Once changed, they (generally) stay that way.

 About this document...

Review: click here.

Audience:

For people who need to create files and put them on the Web in a logical, organized fashion.

Objectives:

When you successfully complete this lesson, you will be able to...
  1. Describe the hierarchical organization structure of computer files;
  2. Express the relationship between files in related directories using relative link notation;
  3. Use file names that work well on all computers that access the Web;
  4. Organize files on local disks in a way that parallels the organization of the Web site for which they are intended.

Module W50c:

This document is part of a modular instruction series in Computer Information Systems. For more information, see the overview or the list of modules in this series, W: World Wide Web. This document has been used in the following classes: CIS 260, INP 143.

Author:

Laurence J. Krieg

Institution:

Department of Computer Information Systems, Washtenaw Community College
History: Original: 29 Nov 1998
Last modification:  Monday, 31-Aug-2009 11:48:06 EDT
Copyright: Copyright © 1999, Laurence J. Krieg.
Instructors: You may point to this file in your Web-based materials.
Students: you may make a copy for your personal use.
All other uses: contact the author, Laurence J. Krieg for permission. Email krieg@ieee.org