Dashes Vs Underscores In URLs

0 comments suggest edit

I used to think the choice of using dashes vs underscores to separate words in an URL was simply a matter of personal preference. Nothing more than a religious choice.

Personally, I preferred underscores because I felt dashes intruded upon the words while underscores stayed at the bottom out of the way. So much so I had originally made that the default URL scheme in Subtext for friendly URLs and was using that myself.

It wasn’t till recently that I learned this debate has already been resolved. Years ago.

I wouldn’t say resolved really. Just that, there appears to be a really good reason to choose dashes over underscores. Apparently, Google sees the dash as a word separator, while the underscore is perceived to be part of the word. Something to do with being able to search for C++ style constant variables SUCH_AS_THIS in the title of a post.

The question is, does this still apply today? Does iteven matter?

To be on the safe side, I’m falling in line for now. Or rather, in dash. What are your thoughts?

Found a typo or error? Suggest an edit! If accepted, your contribution is listed automatically here.



21 responses

  1. Avatar for simoncox
    simoncox March 15th, 2007

    I am glad someone else is bringing up this debate again. For me it has not been resolved because the accepted way is for programming not for the common language usage of hyphens. Google got this wrong and have not put it right yet, or have they...

  2. Avatar for Rob Conery
    Rob Conery March 15th, 2007

    Underscores are terribly hard to see at times, and more than once (when a word is underlined or part of a hyperlink) I've misspelled the URL or just missed it altogether.
    Dashes, em-dashes, hyphens: it's all pretty confusing idn't it? I mean what do you do when a post title has a dash in it? Remove it only to put it back :)?

    For me it has not been resolved because the accepted way is for programming not for the common language usage of hyphens

    Isn't that what we're talking about?

  3. Avatar for Steven Harman
    Steven Harman March 15th, 2007

    Good thing we made that totally configurable in Subtext. It took me all of 3 seconds to change the URL construction for my blog - and 2 of those seconds were spent navigating to my site's web.config file.
    Also... when did you change Subtext to add the "author" class around the comment div for the Comments.ascx control?

  4. Avatar for James Chen
    James Chen March 15th, 2007

    Dashes bring better readability than underscores, especially when the URLs are displayed on pages with the underline style.

  5. Avatar for Jay Flowers
    Jay Flowers March 15th, 2007

    There is more on the why here:

  6. Avatar for Jeff Atwood
    Jeff Atwood March 15th, 2007

    That's right. It's all about regex. Try a \W (word character) match and see what happens.
    I also agree with the earlier comments that underscore sucks for other reasons. It's less comprehensible.

  7. Avatar for Jayson Knight
    Jayson Knight March 15th, 2007

    Hyphens all the way here...much more readable IMO.

  8. Avatar for Maurice Prather
    Maurice Prather March 15th, 2007

    Who cares?
    As a human, it doesn't really matter. Yes, there are some points about readability vs. typeability vs. recognizability. As long as I can recognize the url as a url, I'm good. I can always cut/paste, click on a link, etc.
    As a search engine, this should absolutely not matter. If a search engine is relying on a url to give a page relevance (even if the contribution percentage is small), then I would say that relevance calculation is broken. Content matters, not the url.

  9. Avatar for Dave Frank
    Dave Frank March 15th, 2007

    If you surf around botw:
    you'll see that we use underscores for spaces in the URL. Why? because it looks nicer than %20 which spaces tend to show up as, more often than not. If you had dashes for the spaces, and then had a word with a dash in it, the system could get confused.
    You can see what happens with these category names:
    Wolverine-Hoosier Athletic Conference
    2gether - The Series
    Northeast-10 Conference
    Northern Illinois-Iowa Conference
    Magazines and E-zines
    Magazines and E-zines
    Have Gun - Will Travel

  10. Avatar for Scott
    Scott March 15th, 2007

    Know why I hate 'em?
    C & C++ folks overused them. Quick, how many underscores in this constant. Change your font, now how many? Argh!

  11. Avatar for Haacked
    Haacked March 15th, 2007

    The dash being easier to type is a GREAT consideration.
    Originally, I used Wikicasing for my URLs. Now I'm trying out dashes. It's like the fashion style. I'm wearing what's en vogue.
    Tomorrow I'll use another character. Maybe the "Y"!

  12. Avatar for Haacked
    Haacked March 15th, 2007

    > Also... when did you change Subtext to add the "author"
    > class around the comment div for the Comments.ascx
    > control?
    Last night.

  13. Avatar for German Rumm
    German Rumm March 15th, 2007

    I'm using dashes. Because of Google and because it's prettier.
    Underscore is not even a character. Historically, it's a type-writer "hack" - to make it easy to underline words.
    Computer keyboard was copied from type-writer, and that's why we have underscore and QWERTY layout.

  14. Avatar for Robb Allen
    Robb Allen March 15th, 2007

    You can have my underscores when you pry the bits from my cold, dead, L2 cache.
    Honestly, I'm agnostic, although anything that irritates Google is good for me. Google is NOT the MCP (anyone else remember Tron?) and we should not force our coding standards to make Google's life easier. Google is supposed to adapt to us, not vice versa.
    That being said, dashes are easier to read, for sure.

  15. Avatar for Ryan Smith
    Ryan Smith March 15th, 2007

    It's funny that Atwood brings up the point that the regular expressions are easier to write in order to parse the URLs with dashes.
    I had the exact opposite problem. I would run a regular expression on my friendly URLs to make sure that there were only valid alphanumeric characters. The dash would break this so I had to rewrite my regexp.
    Not that this was difficult, but I never looked at from the other point of view.

  16. Avatar for Tom's Blog
    Tom's Blog April 23rd, 2007

    Dashes Vs Underscores In URLs Dashes Vs Underscores In URLs .

  17. Avatar for David Huntley
    David Huntley June 4th, 2007

    I'm i not correct in thinking that domains can not contain an underscore character if you want to have compatibility with IE and cookies? Surely that's reason enough to switch if you haven't.

  18. Avatar for Timothy (TRiG)
    Timothy (TRiG) January 18th, 2009

    It's true that underscores are not allowed in domain names, but they're perfectly valid in the rest of a url (just as question marks, ampersands, and solduses (soldi?) are).
    That said, I think some domain name registries do allow underscores in domain names, which they really shouldn't. In fact, that's what I was looking for when I came here.
    On this subject, I like the look of underscores, because they more clearly separate words, while hyphens bring words together. That's their function in language, and I like to differentiate. But hyphens are easier to type, so I'm undecided. So far, I've gone with hyphens. Camel case is evil.

  19. Avatar for Đồ gia dụng
    Đồ gia dụng January 10th, 2013


  20. Avatar for Đồ gia dụng
    Đồ gia dụng January 10th, 2013

    Thanks for sharing

  21. Avatar for numediaweb
    numediaweb March 1st, 2017

    10 years later..

    Here are a few points in favor of the dashes:
    * Dashes are more familiar to the end user.
    * Dashes are easier to write on a standard keyboard (no need to Shift).
    * Dashes don't hide behind underlines.
    * Dashes feel more native in the context of URLs as they are allowed in domain names.