File naming conventions for websites

Websites are archives. A website that isn't an archive is one that displays a lot of "404 errors" - file not found.

Perhaps more than other kinds of archives, it's important to plan the archive out for accepting new files for a long period of time. That's because websites get links, or what some call "deep links", which are links on pages past the so-called "home page". (I think it's a stupid distinction - a home page is only for branding and frequent users, and there are few of the latter. Most traffic comes from links and search engines.)

When you rename or move files, you break all the links out there. That's the fabric of the web.

To avoid this problem, you have to break up your system into manageable chunks, and you have to do it from the start.

If you expect to upload new image files every day, you should plan to have a system that can handle 365 files per year, and 3,650 files per decade. A single folder might be sufficient for the first 365 files, but, things get unwieldy at 3,650 files if you have to look at the files and pick them. Even the network will slow down when you get a file listing.

The solution for that is to use dated folders.

If you expect to get few images per year, except during events, when you get hundreds of images. The obvious solution is to create one folder per event.

I like to prepend the year to the event, so you get names that sort by date, like 09picnic. If that's not precise enough: 090815-picnic.

Uppercase?

You can use upper and lower case, but at your peril. Windows and Mac are case insensitive, but Unix is case sensitive. That means in Unix, "Car.jpg" is different from "car.jpg", and both are different from "car.JPG".

On Windows and Mac, all three are the same file. The hazard is that you create the three files on Unix, and then copy them to a Windows or Mac, and end up with only one file (or an error).

The convention is to use all lowercase for naming files on Unix.

To avoid problems, rename your Windows files in lowercase if they are destined for the Web.

Separate HTML files from image files?

Most websites have all the images in an images directory, and the HTML files are in other directories, or are in the "root" of the server. (the topmost directory).

This is probably because a single HTML file tends to include more than one image. Thus, as the site grows, moving images into their own directory just makes sense - it's a quick fix to the problem of growth.

Suppose each page includes three images. Then, each new page causes four files to appear on the server. 100 pages later, there are 400 files.

By moving images into a directory, the 100 pages cause only 100 visible new files in the directory.