Spaces in Filenames and Why You Should Avoid Them on the Web

For most of us, naming files is a simple task to which we don’t give a lot of thought. You give a file a descriptive name to make it easy to distinguish (e.g., “Meeting Minutes June 2011”) and click the Save button. On your local computer, this isn’t an issue; however, if you plan to put that file on the internet, you may want to think about its name. Let’s take a look at a few things you should consider when naming files for use on the web in your Blackbaud Sphere CMS site.

In the example above, the main challenge comes in the form of spaces. Let’s assume this was an MS Word® file. Our filename then is actually “Meeting Minutes June 2011.docx”. URLs don’t allow for spaces. That means that your browser is going to have to encode those spaces, usually with the ASCII code “%20”. Most modern browsers do this just fine, but if for some reason it fails, you’re going to end up getting a “page not found” error when you try to access the file.

A recent example of this occurred for a Blackbaud Sphere customer. They had a file with spaces in the name that was hosted in their CMS site. They then referenced this file in an email using a tracking link. This process requires the original URL to be encoded and decoded several times. At some point in the process, the encoding failed and their supporters got a “page not found” error when clicking the links in the newsletter. Blackbaud Sphere’s product development team will be working to update our encoding process in a future release, but the issue could have been avoided entirely by removing the spaces from the filename.

URLs generally consist of alphanumeric characters. You can also use the following characters in your URLs:

– _ ! * ‘ ( )

While other characters can be included, it may not be safe to do so as they may have special roles in the URL. For example, the following characters all have functional roles within URLs and may need to be encoded if they are being used in some other way:

? & = +

So in our original example, a better filename would be “Meeting_Minutes_June_2011.docx”.

As systems become more sophisticated, many of the issues caused by encoding URLs may disappear. In the meantime, it makes sense to stick with best practices and avoid spaces and special characters in your URLs. Developing good naming conventions makes good sense.

3 Responses

  1. Great tip!  Usage of either underscores or dashes between words in file names will also ensure better search engine optimization so your website–including documents–can more easily be found by constituents.

  2. I would think it would make it EASIER, in some cases, to use underscores. If I want to find a file that I know is called “Word1_Word2.doc”, I can search for that and find the file quickly rather than thousands of sites with “Word1″ and “Word2″ in them.

  3. I disagree with this type of reasoning. Instead of working around the shortcomings of crappy applications / tools, the tools should be fixed.

Similiar Posts

    None Found