Take the 2-minute tour ×
User Experience Stack Exchange is a question and answer site for user experience researchers and experts. It's 100% free, no registration required.

Possible Duplicate:
Underscores vs. hyphens in URLs

I'm going to implement a sort of "friendly url" for geography like a regex

/<region>/<city>/<category>?

and then I wonder which type is best:

/new_york

or

/new-york

I can understand advantages and disadvantages with both ways of writing the name. Which way do you think I should represent the whitespace? I'm passing on the name to a geocoding lookup that encodes the whitespace with this python code

param = {"address" : region,
        "sensor" : "false"
       }
encoded_param = urllib.urlencode(param)
url = 'http://maps.googleapis.com/maps/api/geocode/json'
url = url + '?' + encoded_param
result = urlfetch.fetch(url)
jsondata = json.loads(result.content)
latlng = jsondata['results'][0]['geometry']['location']
lat = latlng['lat']
lon = latlng['lng']

And the result will have the longitude and the latitude of for instance New York and doing it this way it will work for any region and city. Could you please answer, comment my whole scenario or just say if you prefer a slug like new_york or new-york.

Thanks in advance

share|improve this question
2  
Will your friendly URLs survive chopping .. that is, what will happen if someone takes /us/new-york/shoes and truncates it to /us/new-york ? –  Erics Dec 10 '11 at 6:30
1  
Dashes are generally more common. I personally find the _ underscore very ugly and old fashioned but that's just opinion. Slightly more objectively I don't see it used very often any more. –  Ben Brocka Dec 11 '11 at 1:53
    
dashes are easier to spot in print and Google (SEO) prefers dashes as word separators. Thus, dashes win. –  DA01 Dec 11 '11 at 23:16
add comment

marked as duplicate by Patrick McElhaney Dec 12 '11 at 13:41

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

4 Answers

up vote 8 down vote accepted

I don't think there is any difference from a UX standpoint. But I'd say dashes are much more common and common is good. :)

PHP content management systems like Drupal and WordPress prefer dashes. In the past, Matt Cutts at Google has also recommended dashes:

http://www.mattcutts.com/blog/dashes-vs-underscores/

Edit: Google recommends dashes/hyphens too: http://support.google.com/webmasters/bin/answer.py?hl=en&answer=76329

share|improve this answer
    
Good answer. I think a good argument is that dash is easier to pronounce as well. –  909 Niklas Dec 12 '11 at 8:12
1  
Depending on the rendering engine and font - when underlined as part of a link, underscores are virtually indistinguishable from spaces (eg compare a-link-with-dashes vs a_link_with_underscores (may need to hover here on ux.se) - so dashes are better from that perspective too. –  Roger Attrill Dec 12 '11 at 10:08
add comment

There might be difference from UX position. "-" is way more common than "_" and it might affect users.

The question is how are you going to expose users to those links and if they really will notice them.

share|improve this answer
    
Also technically a python filter named slugify makes a format with dashes and it can be good to be compatible with a known algorithm that also has implementation for special cases such as escape chars and foreign characters. –  909 Niklas Dec 12 '11 at 8:14
add comment

Dashes tend to be more readable, and perhaps even less "techy", than underscores.

share|improve this answer
    
Thanks for the answer. I agree. –  909 Niklas Dec 12 '11 at 8:14
add comment

Not professing to be a UX pro by any means, but could dashes be easier for the user because a) typing an underscore requires the use of the shift button in conjunction with the key and b) when reading, a dash is in the center of the words, assisting the flow of the eye. An underscore is at the bottom of the words, perhaps subtly drawing the eye down and creating a small distraction.

Just a couple of thoughts.

share|improve this answer
    
Thank you for the answer. I'm likely to choose dashes now. I think that dash is easier to pronounce as well. –  909 Niklas Dec 12 '11 at 8:13
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.