2.3. Organizing Your Files in Directories

Problem

You need a plan for putting site assets in their proper place, so you and others who work on the site can easily find and update the right file at a later date.

Solution

Group your files by content, method of creation, and access level, and then create directories on your web server where they can be uploaded and modified as needed.

From a command-shell prompt, you can create a directory with the Unix mkdir command. A full-featured FTP client or WYSIWYG site management applications should offer a menu command for creating directories on a remote server as well.

Discussion

Don't build a site where every file commingles with every other file in an unorganized mess at the top file level of your web server. Well-planned web site organization requires a lot of advance planning, but pays dividends as your site grows and changes. Try to mirror your web site's navigation—the links and buttons that visitors follow through your site—but keep in mind some of the limits of the server file system as you do.

Unlike the folders you create on your desktop PC, web site directory names should not contain spaces. The server will convert spaces to the unaesthetic (but not unusable) encoding %20. Likewise, avoid special characters: The server might mistake ampersands (&) and questions marks (?) for delimiters in a CGI script argument; the number (or pound) sign (#) is used in HTML markup to create a link to another section of the same web page. Hyphens and ...

Get Web Site Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.