Usable file and directory names make usable URLs
Summary
Thoughtful and consistent naming of web files and directories can improve usability and site maintenance.
File and directory names as URLs
On the web, file and directory names usually make up part of the URL for web pages. URLs are used in a variety of ways. We:
- Type them into web browser location boxes
- Write them in emails to colleagues, and in reports and other types of documents
- Communicate them to others verbally--on the phone, in meetings, when talking to friends
- Guess them--experienced web users will often try this as an alternative to other means of finding information online.
So, the way you name your web files and directories has implications for usability. The following is a short list of guidelines that will improve the usability of your URLs.
Use whole words rather than abbreviations
Use whole words in file and directory names where possible. If you must use an abbreviation, only use one that is widely known amongst the users of your site.
It is much easier for a user to remember, to read out (on the phone to a friend, over a desk to a colleague), or to type in a URL where whole words are used.
Advanced users who attempt to locate information by guessing URLs will be more likely to find information on your site if you use whole-word file names or common abbreviations.
Using appropriate whole-word names also makes site maintenance easier. A file named refunds.html in a directory named policies can be readily identified as the policy on refunds for sales to clients of your company, even by someone who didn't create the file.
Don't use spaces or non alpha-numeric characters
Never use spaces or non alpha-numeric characters in your file names. These are not legal characters in URLs and will be converted to their hexadecimal equivalent, which is then preceeded by a percentage sign (%). This conversion results in some pretty ugly URLs that can be difficult to type, communicate or remember.
For example, a file named my holiday.html, in a directory named travel info would be translated to travel%20info/my%20holiday.html
Avoid using underscores
If you must visually separate a two-word file or directory name, use a dash (hyphen) rather than an underscore.
When hyperlinks are formatted with an underline it is usually not possible to see the underscore. For instance my_file_ name.html would become my_file_name.html. Some users may assume that the URL contains spaces, and may then be unable to find your web page.
Use all lower case characters
It is best to use all lower-case characters in file and directory names. Although not all web servers are case-sensitive, most are (at least at this point in time), and if users get the case wrong, they won't find your page.
Combinations of upper- and lower-case characters in file and directory names are more difficult to type and to remember for both users and site maintainers.
Use index files in all content directories
Almost all web servers are set up to look for a default index file, usually namedindex.html, but sometimes default.html or welcome.html (check this with your web server administrator). This is the file that is loaded when a directory URL is used. For example, using the URL http://www.deyalexander.com.au/resources/ will result in the file index.html in my directory named resources, to be loaded.
Every web content directory should have an index file. This is usually a page that would provide links to the other resources located within the directory. There are two good reasons for creating an index file in all your content directories. First, using the default index file name means you can use shorter URLs: http://www.deyalexander.com.au/resources/ instead of http://www.deyalexander.com.au/resources/index.html.
Second, it provides an easy means of preventing users from seeing raw directory listings when they use directory URLs (ie. URLs ending in a trailing slash [/]). This is a better approach than making the directory contents unreadable by using access control restrictions which then results in the user seeing an (oftentimes unhelpful) error message.
Related (external) links
Published: 3 March, 2000
Updated: 24 April, 2008
