I often get asked whether I’d recommend dashes or underscores for words in urls. For urls in Google, I would recommend using dashes. Why? To find out, let’s take a trip in the Google Time Machine. Set the dial for 1999, the year Matt first discovered Google. Matt was using, I dunno, maybe HotBot at that point? The curtain rises:
Matt: Hmm, this search for [FTP_BINARY] didn’t turn out the way I wanted. I got a couple scuzzy looking urls, and the other documents just have the words “FTP” and “BINARY” but the term “FTP_BINARY” doesn’t actually appear. (Note: Matt was a bit of a nerd, as you can tell.)
Some Random Person That I Don’t Remember: Have you tried Google?
Matt: What’s that?
SROTIDR: It’s a search engine written by nerds for nerds! They index numbers! Sometimes they even index punctuation, like “C++”. Try your underscore search there.
Matt: Okay, here goes. Whoa! They actually return pages with the literal string “FTP_BINARY”! That’s wicked cool! (Did I mention Matt was a nerd? Big-time nerd.)
SROTIDR: Yeah. The wild thing is that they wrote a paper about how they crawl the web and rank pages.
Matt: Well, now that’s just silly. I wonder why they didn’t keep it a secret? I bet those papers will make great reading for my information retrieval class.
I’ve stylized the conversation quite a bit, but I remember how impressed I was that Google indexed numbers and some punctuation (come to think of it, search engines have come a long way in five years). With underscores, Google’s programmer roots are showing. Lots of computer programming languages have stuff like _MAXINT, which may be different than MAXINT. So if you have a url like word1_word2, Google will only return that page if the user searches for word1_word2 (which almost never happens). If you have a url like word1-word2, that page can be returned for the searches word1, word2, and even “word1 word2”.
That’s why I would always choose dashes instead of underscores. To answer a common question, Google doesn’t algorithmically penalize for dashes in the url. Of course I can only speak for Google, not other search engines. And bear in mind that if your domain looks like www.buy-cheap-viagra-online-while-consolidating-your-debt-so-you-can-play-texas-holdem-while-watching-porn.com, that may still attract attention for other reasons. 🙂