Which is better for search engines?
Webmasters Stack Exchange is a question and answer site for pro webmasters. It only takes a minute to sign up.Sign up to join this community
Although there seems to be less difference now than there was in the past, hyphens are recommended if you want each of the terms in your URL recognized as an individual word.
The reason for this is that search engines find it easier to treat hyphens as word separators, just as they are in the English language. Underscores, however, are not normally used in English as word separators. In many cases it is desirable to see them as part of the characters before and after them, for instance when underscores are used in function names for programming, and other similar situations.
There are a couple cases where this might matter. For one, if someone uses the full URL as the anchor text for a link, then the search engines will be able to pull out those terms as relevant words. For another, it is possible that search engines use words in the URL as correlative factors to determine the relevance of those terms to the page content.
Matt Cutts has a dated piece that explains this, and there is a more recent Google Webmaster Help video from August 2011 saying that Google still does not treat underscores as word separators. You may as well make life as easy as possible for the search engines, for the same reason that you give them valid HTML.
If you are starting a new site, you are definitely better off using dashes.
This article by Jeff Atwood always clinched it for me: Of Spaces, Underscores and Dashes:
This_is_a_single_word, but this-is-multiple-words.
... though this no longer seems to hold in the case of Google (try searching for "web-site": it is considered as one word).
I personally think dashes are easier to type than underscores because you don't need to press shift to get them. I'm also wondering if many people would even know where to find the underscore on the keyboard.
Of course, this isn't a big deal because most users are not typing in website addresses, but it's possible someone might be at sometime.
For me, it's easier to read hyphens than underscores. I think it's probably easier for most other people too.
Hyphens are treated as word dividers, which help your page names be seen as real words, which is a good thing.
Underscores, in many, if not most, cases are not treated as word dividers, which renders a page name as a big cluster of letters and underscores.
This means that -- all other things being equal -- your pages will score lower in most places if you use underscores rather than hyphens in your pages names. How much lower? Not much. Will this always be the case? No.
What's better for search engines?
Doesn't matter. What does matter is: What's better for users?
A modern search engine shouldn't rely on strange rules of what is a word separator and what is a word joiner or whatever. Modern search engines can deal with typos, apostrophes, punctuation, etc. Figuring out which characters separate words shouldn't be much of an issue.
I disagree with the people who claim that hyphens are better because they are natural word delimiters. They kind of are, but kind of aren't: they make words semi-attached or semi-delimited. The natural word delimiter is %20.
But the above statements are irrelevant. The URL shouldn't be important anyway.
How important are the keywords in the URL?
They shouldn't be important, if they are there's obviously no content on the page.
URLs aren't very visible for humans: links may have anchor text instead, it's not shown on the page and it's not shown on the browser tabs.
The <title/> and the main heading are more visible and usually contain the same keywords anyway making the keywords in the URL redundant.
How important is it for humans?
From a search engine point of view: not at all, the user only needs to enter a search query and click on the snippet with an interesting title and description.
But visitors come from other places too. In some cases, there's a nice anchor text instead making the "URL quality" irrelevant, but there are cases when it does matter.
Quick&dirty copy-pasting/sharing of the URL: no issue for the writer, but it does matter for the reader.
Needing to enter the URL manually. (Can't copy text from an image for instance.)
What determines the quality of a URL?
Length; You don't want address bars to scroll horizontally or URL only links to linewrap. And needless to say: it also takes longer to type a longer URL.
Word delimiters; It appears that most people agree on that hyphens are better.
Clutter; Eg: Unique IDs, filename extensions, weird URL parameters. These are difficult to remember.
Strange characters and syntax; An outdated example would be tildes (http://example.com/~user/), but URL parameter syntax is a bit strange too. Any uncommon character might be difficult to type for some people.
Safe characters vs Unicode; This is a two edged sword and deserves its own answer. But briefly: browsers mangle URLs, %c3%a4 etc is a pain in the ass to type, not every keyboard can enter the unsafe characters, possibly some encoding hell, but the keywords make sense for native speakers.
Length of the text; Consider the URL to be a form of a title, don't waste words mentioning the obvious and ignore grammar.
People will type something slightly different
Your webserver should be designed to redirect recognized non-canonical URLs to their canonical version. It's up to you to decide:
http vs https
www vs no www
trailing slashes vs no trailing slashes
But your server needs to accept and correct all of them.
A 404 page with search results would be nice for the user. (Use the words from the URL as the search query.)
Google is pretty clear that they prefer hyphens:
We recommend that you use hyphens (-) instead of underscores (_) in your URLs.
In short - Google views hyphens as word separators in a URL, making it much easier for Google to identify words and figure out what the page is about. Underscores and plus signs can have multiple meanings and are less clear to Google.
It depends from what you want to express with the URL:
On the surface, it’s easy to believe that hyphens and underscores are treated the same by search engines. However, this is not the case.
In short, Google treats a hyphen as a space (or word separator). So, while you may not be able to add a traditional space, it still appears this way in the eyes of Google.
An underscore, on the other hand, is considered a “word joiner.” Sticking with the example above,
miami_real_estate_agentis the same as