04 Sep 2005
Finishing Touches: Useful URLs
Tidy, human-readable URLs look better to users and increase traffic from search engines. It’s easier than ever to implement them, with simple rewriting technologies available for pretty much every development platform, yet developers are still churning out rubbish. Look at a couple of typical pages from MSN Spaces, for example:
Want to do better than Microsoft? Here's what I’ve learned from building this site and countless others:
- Think of the browser’s address bar as part of your site’s user interface.
- Consider URLs to be part of the site’s architecture; think about them during planning phases.
- Try to choose a structure that’ll last, to help avoid disruption in the future.
- Strike a careful balance between clarity, consistency and brevity when picking folder names.
- Keep everything lowercased for simplicity and consistency.
- Use hyphens to separate words; search engines recognise them as word separators, and they don’t get obscured by underlines as underscores do.
- If a URL is for use in offline promotional material (e.g. print or radio ads), it needs to be particularly short, unambiguous when read/heard, and easy to type. Sometimes those priorities clash with the needs of the site, in which case set up redirects for the promotions.
- Hide technology away as much as possible. There’s no need to expose all the
- Where there’s a hierarchy, reflect it in the folder structure, e.g. ‘Multimedia’ is within ‘Services’, resulting in
- If your site has a static structure (i.e. it’s created with files, not dynamically from a CMS), make use of folders and default documents, e.g.
- If your site’s dynamic, use some form of URL rewriting to divert requests behind the scenes, so you don’t need actual folders and files. Apache has mod_rewrite, and for IIS there are various ISAPI filters and ASP.NET features.
- Always make sure a helpful 404 error page is returned if the page requested doesn’t exist, don’t serve up the home page or forget to set the status code (which often happens when people rewrite URLs).