urlseparatorurl-designcasing

What's the best practice for URL path casing and spacing?


I want to know what is considered a good practise for casing and spacing in URL paths.

Casing:

Spacing:

../data/upload_data  
../data/upload-data  
../data/uploadData  
../Data/UploadData  

What do you think? Which is better?


Solution

  • Three common URL designs:

    Pro separator: It’s easier to see what the string means; and you can avoid misunderstandings (think of teacherstalking: teachers talking, teacher stalking). While CamelCase could help here, it doesn’t work so well for longer strings, e.g., whats-the-best-practice-for-url-path-casing-and-spacing is easier to grasp than WhatsTheBestPracticeForUrlPathCasingAndSpacing.

    Pro correct case: If your site has pages about different things written the same except for different case (e.g., "Stack Overflow" for the site/company, "Stack overflow" for the programming concept; or "Love" for the noun, "love" for the verb), this is a simple way to disambiguate.

    Pro CamelCase: Words written that way can automatically be linked to their corresponding pages; authors don’t have to use hyperlink markup.

    Unless your site is a wiki with many authors that don’t know markup so well (in which case CamelCase might be helpful), or something like an encyclopedia that defines things that are typically described by one or only a few words (in which case correct case might be helpful), I would go with the most popular way: use lowercase and the hyphen (-) as separator. This is what people are used to see.

    Google recommends this, too:

    Consider using punctuation in your URLs. The URL http://www.example.com/green-dress.html is much more useful to us than http://www.example.com/greendress.html.

    We recommend that you use hyphens (-) instead of underscores (_) in your URLs.