postheadericon Naming Files and Folders: Play it safe

Whether you are embedding an image file in your HTML email, or pointing to a hosted document on a web server, adhering to known file naming conventions and best practices rids you of a lot of headache. So, what should and should not be in the file name?

Here are some things to avoid when naming files or folders for use in your HTML addressing:

  • Spaces: Never use spaces in file or directory names. While Windows operating systems do allow using spaces, having spaces in file names increases your chance of getting broken links and page errors instead of your content. (e.g. www.mydomain.com/my file.pdf)
  • Special Characters: Those are characters that have a special meaning in a URL. Any character that is not a letter, a number, a dash, or an underscore (e.g. http://www.mydomain.com/my*site’s#images/mail!job.gif)
  • Periods (dots): Unless they immediately precede the file extension, dots should not be used when naming a file or folder (e.g. http://www.mydomain.com/my.folder/my.file.pdf)
  • Name Length: Theoretically, you can use up to 128 characters or more in the file name, depending on the operating system. In practice though, some software applications would break or truncate long file names. Your file name should be no longer than 32 characters, including the file extension.

The other thing you need to watch for is that some web servers, such as UNIX/Linux and Macintosh system, are case sensitive. On case-sensitive servers, requesting a file like My_Document.pdf is different from a file request for my_document.pdf. Therefore, it is probably a good idea to come up with a naming convention for your files and folders so that you are more consistent and the risk of getting broken links due to typographical errors is greatly minimized. Here are 3 tips on creating a naming convention:

  • Instead of spaces, use either underscores or a capitalization scheme to separate words. Make sure you correctly capitalize your file names in URLs and test them if you choose to go with the latter. (e.g. my_image.jpg or MyImage.jpg)
  • You might just want to use all lower case format to reduce possibiltiy of errors, especially when files are hosted on case-sensitive web servers. (e.g. mydocument.pdf)
  • Choose file names that are readable and meaningful so that you can easily identify and refernce them to source documents and images.

All that applies to files above should apply in the same way to folders that make up the directory structure on the web server. If you want to read more about standards and specifications for Uniform Resource Locators (URLs), check out this publication by w3.org.

Leave a Reply