Best Practices – Do’s & Don’ts for File Names
Something as simple as a file name can easily cause problems with a website. Whether it’s an image that appears to be missing, a web page that shows HTML code, or an error on the website – these problems can all stem from a file name.
Why Does My Page Show HTML Code?
It’s one of the more common questions we receive which is caused by an invalid file name. Internet Explorer will try to display a file as a web page if it’s not sure what type of file it is, but other browsers such as Firefox will show the file as text. If you forget to put an extension on your file name (ex: .html) Firefox will just display the HTML code inside your file.
TIP: Always make sure your web pages have a correct file extension such as: .htm, .html, .php, or .asp. (ex: myfile.html) Use .htm or .html if you are unsure what to use, or check with your developer for their recommendation.
Why Isn’t My Image Working?
This is another common issue caused by a wrong file name. If an image is a .jpg file, but the file name ends in .gif then Internet Explorer will not display it. Incorrect extensions on image files can cause a variety of issues depending on the file type and the web browser – with the most common being that the image is not displayed at all.
Incorrect extensions on images will also cause a ShopSite store to be unable to create resized versions of the image. If an image is not resizing – check that the file you created has the correct extension.
TIP: Be sure that your image files end with the correct extension for their file type. (ex: .jpg, .gif, .png)
Random Errors and Missing Files
While file extensions do lead to the most common issues with file names, the characters used in the file name itself can cause issues as well. For example the “&” character is reserved for use in the browser’s URL so when it’s used in a file name the page may appear with errors or may not work correctly at all. Other cases such as capital letters used in a file name but not in a URL can cause a page to appears as missing since web servers that run Linux are case-sensitive.
File Name Recommendations:
- File names should contain only letters, numbers, underscores, and dashes
- A dash or underscore should be used instead of a space
- No special characters (& ‘ ” ; : * ! # $, etc)
- Lowercase letters are recommended for consistency, but uppercase or a mixture will still work fine
A filename is often overlooked as the first cause for an issue on a website, but you can save time and frustration when diagnosing a problem by ensuring that your files do not use any special characters in their names and they have the correct extension for the file type.