URLs - use "-" or not (your opinion)

Hi, i am trying to decide what i should rename all of my urls to.

I am going to remove all the “.html” endings but what is your opinion on the following:

Should i use “-” or not… for example:

/sign-in OR /signin OR /sign
/create-account OR /createaccount OR /create
/my-account OR myaccount OR /account

What is your opinion on the above, what naming mechanism should i use, thanks in advance…

Interesting question for admin pages.

For things like articles I would do…

articles/why-you-should-start-your-own-business-today

Debbie

I guess this is a SEO question and I just got finished with a bit of research on that topic.

Use a hyphen, Google interprets sign-in as sign in whereas sign_in becomes signin to the results.
If you don’t have any keywords in your URL (you should) you can go without the hyphen but your URL’s look funny, sometimes if you group words together you get a middle word that may be undesirable, also try to pronounce signin as one word.

My 2c

Yes; hyphen is considered as space by google. Hence, it is advisable to use hyphen to separate words in urls.

I just find it amusing that NOBODY uses the actual official spec for doing this - RFC-3986 because “percent signs are ugly”… or use PHP’s in-build URLEncode because “plus signs are ugly”.

Personally, I prefer underscores to hyphens visually, but I know I’m in the minority on this and search engines treat underscores as literals, which is why I go ahead and use hyphens despite my dislike.

Usually I use these to decode/encode URL’s these days:


function urlEncodeHyphen($url) {
	return str_replace(
		array('-','+'),
		array('%2D','-'),
		urlencode($url)
	);
}

function urlDecodeHyphen($url) {
	return urldecode(str_replace('-','+',$url));
}

A simple test:


$testString='This is a test - or is it? 2+2=4';
echo '
<pre>
    raw :',$testString,'
encoded :',$encoded=urlEncodeHyphen($testString),'
decoded :',urlDecodeHyphen($encoded),'
</pre>';

Outputs the following.


    raw :This is a test - or is it? 2+2=4
encoded :This-is-a-test-%2D-or-is-it%3F-2%2B2%3D4
decoded :This is a test - or is it? 2+2=4

Safely encoding the characters that aren’t allowed in a URI, using hyphens instead of plus signs for spaces…

Though it does raise a question, how do search engines treat the PHP urlencode plus signs? The output from urlencode being:
This+is+a+test±+or+is+it%3F+2%2B2%3D4

For the above test string.

I always like URLs to be as short as they can without losing information. So “My account” would be /account and “Create account” would probably be /create.

If you’ve only got a couple of words and you’re not going to run into the “Pen Island” problem, there’s no real harm in leaving the hyphen out, but once you get beyond that, run-in becomes difficult to read and parse, eg website.com/pagenamemadeupoflotsofwordsstrungtogether. Google will probably be able to make sense of that, but people will struggle, so you need some kind of word delimiter.

The biggest problem with underscores is that when the URL is typed, it is usually underlined, and it isn’t always obvious to the uninitiated when you see website.com/page_name_with_underscores that those are underscores and not spaces.

So by a process of elimination, most of the time you’ll be best off using hyphens to separate words in the URL.

Which is an EXCELLENT point – write for people, NOT the search engines. All the black hat SEO BS in the world is pointless if the result isn’t useful for PEOPLE.

Cool, thanks for all your help guys… much appreciated…

Use hyphen in url but only one time not use more and more time in URL.

what? where did you come up with this?

sure sounds like nonsense to me

Hi, As per my opinion we never use hyphen cause i think crawler consider hyphens as a junk character. and little bit negative impact on this. I’m not sure about this. i just explain what i think. might be i’m wrong. Hope you understand my point of view.