Jump to content

Pretty URLs and + - _


doubledee

Recommended Posts

I think you are putting more work into this than you need to. There is already a function in PHP to convert a vaue into an URL acceptable value. urlencode(). You would then use the opposite command, urldecode() on the values passed through $_GET to convert them back to their original value.

 

Using the urlencode() function, spaces are converted to plus signs. Other "special" characters are converted into appropriate codes.

Link to comment
Share on other sites

I think you are putting more work into this than you need to. There is already a function in PHP to convert a vaue into an URL acceptable value. urlencode(). You would then use the opposite command, urldecode() on the values passed through $_GET to convert them back to their original value.

 

Using the urlencode() function, spaces are converted to plus signs. Other "special" characters are converted into appropriate codes.

 

Good point, but I am manually determining how to convert "Postage Meters: A Great Way to Save Money" to "postage-meters-a-great-way-to-save-money", so that is why I asked.

 

I've always liked underscores for spaces, but it seems the web mainly uses pluses and hyphens.

 

 

Debbie

 

 

Link to comment
Share on other sites

Consider using punctuation in your URLs. The URL http://www.example.com/green-dress.html is much more useful to us than http://www.example.com/greendress.html. We recommend that you use hyphens (-) instead of underscores (_) in your URLs.

 

I think you should consider how search engines will pick up the URLs also.. So its best not to user underscores.

 

Have a read here :)

 

http://www.google.com/support/webmasters/bin/answer.py?answer=76329

Link to comment
Share on other sites

That quote is regarding using punctuation in the "base" url - in that case the file name. The OP's question is regarding parameters on the URL. Even Google uses the plus symbol for spaces in the search term. Do a google search for multiple words and check the URL that is generated when you click the search button. Granted there are a ton of parameters generated, but the parameter for "q" will show the search terms separated by a plus symbol.

 

It is inadvisable to come up with your own logic for this. The plus symbol is the internet standard. If you ever wanted to pass information to another service or receive information from another service more work would be required to do so if you aren't following standard protocol.

Link to comment
Share on other sites

In reference to the "pretty URLs" part and not encoding your URLs, typically a hyphen is favored over an underscore. But that doesn't mean underscores aren't used. You check any Wiki and 99% of the time (if using MediaWiki) the page titles use underscores for separation. It's not common in most websites but I've seen it around. Personally I favor the hyphens, but you can use what you want. :)

Link to comment
Share on other sites

In reference to the "pretty URLs" part and not encoding your URLs, typically a hyphen is favored over an underscore. But that doesn't mean underscores aren't used. You check any Wiki and 99% of the time (if using MediaWiki) the page titles use underscores for separation. It's not common in most websites but I've seen it around. Personally I favor the hyphens, but you can use what you want. :)

 

So it sounds like hyphens are best as far as Search Engines are concerned.

 

However, how would you format this Article Title which will become the "pretty" URL...

 

Protecting Your Money:  Debbie's Story

 

(I think it is important to use a non-hyphen for the colon to denote two separate thoughts/parts.)

 

1.) protecting-your-money-debbies-story

2.) protecting-your-money_debbies-story

3.) protecting-your-money+debbies-story

 

Other?

 

 

Debbie

 

P.S.  How do you handle where the apostrophe should be when it comes to the URL?

 

 

 

Link to comment
Share on other sites

Strip out any punctuation characters, quotes, hyphens etc.  They are not needed in the slug and will not help with google.  All you require is something that has words in it that basically match the article title.  Just stick with hyphens for spaces ... so basically:

 

-strip out all punctuation

-replace spaces with -

 

And use that for your slug.

 

This is partly functional (characters that are ok in url's without url encoding) , and partly "search engine friendly"  and "search engine optimization" strategies you are focusing on.  As mjdamato pointed out, you could take the exact title with punctuation and spaces and url encode that, and it will be fine with google.  It just won't look friendly to your visitors, and may discourage them from bookmarking it.  So for that reason, you really want to remove all the punctuation characters and basically anything else that would have to be url encoded. 

Link to comment
Share on other sites

Strip out any punctuation characters, quotes, hyphens etc.  They are not needed in the slug and will not help with google.  All you require is something that has words in it that basically match the article title.  Just stick with hyphens for spaces ... so basically:

 

-strip out all punctuation

-replace spaces with -

 

And use that for your slug.

 

This is partly functional (characters that are ok in url's without url encoding) , and partly "search engine friendly"  and "search engine optimization" strategies you are focusing on.  As mjdamato pointed out, you could take the exact title with punctuation and spaces and url encode that, and it will be fine with google.  It just won't look friendly to your visitors, and may discourage them from bookmarking it.  So for that reason, you really want to remove all the punctuation characters and basically anything else that would have to be url encoded.

 

Okay.

 

(I'd prefer "protecting-your-money_debbies-story", but oh well?!)

 

 

Debbie

 

 

Link to comment
Share on other sites

Strip out any punctuation characters, quotes, hyphens etc.  They are not needed in the slug and will not help with google.  All you require is something that has words in it that basically match the article title.  Just stick with hyphens for spaces ... so basically:

 

-strip out all punctuation

-replace spaces with -

 

And use that for your slug.

 

This is partly functional (characters that are ok in url's without url encoding) , and partly "search engine friendly"  and "search engine optimization" strategies you are focusing on.  As mjdamato pointed out, you could take the exact title with punctuation and spaces and url encode that, and it will be fine with google.  It just won't look friendly to your visitors, and may discourage them from bookmarking it.  So for that reason, you really want to remove all the punctuation characters and basically anything else that would have to be url encoded.

 

I see, I am going to take your advice on this also. Thanks.

Link to comment
Share on other sites

You can use the underscore if you really want -- it's neither here nor there.  It won't be a benefit nor will it be a hinderance to anything that is important.  Of course there are other strings of characters that could be in a title as alluded to previously.  For example, '--', '...'.  It is perfectly fine to substitute an underscore for a colon, but from a logical standpoint, what do you gain of value by adding that complexity?  The slug has no importance other than:

 

-to pass as a parameter to find the article in the database

-to reinforce using words, the title and text of the article, which *may* be of value to some search engines.

-to make nicer bookmarks for people, so that when looking in a bookmark list, they might recognize it some time later when they want to refer back to it

 

Considering this, it's just cleaner to exclude the colon or a special replacement for it, and hopefully it's clear that any consideration of the colon is not important, but if you really want to replace it with an underscore it's not going to hurt anything. 

Link to comment
Share on other sites

Gizmola,

 

Okay, so taking things one step forward, what about my meta tags?

 

Would you favor...

 

<meta name="keywords" content="Postage Meters can save you money!"

 

OR

 

<meta name="keywords" content="Postage-Meters can save you money!"

 

OR

 

<meta name="keywords" content="postage-meters-can-save-you-money"

 

 

 

Debbie

 

 

Link to comment
Share on other sites

Keywords are meant to be a list of "key" words, typically comma seperated. 

 

However, Google for one, just ignores them:  http://googlewebmastercentral.blogspot.com/2009/09/google-does-not-use-keywords-meta-tag.html

 

My bad.  I wrote the wrong thing.

 

Can you please re-answer my question above but replace "keywords" with "description".

 

Thanks,

 

 

 

Debbie

 

 

Link to comment
Share on other sites

The same would apply doubledee, there would be no benefit (probably more of a bad thing if anything) from doing that. Google does use the description meta tag for page descriptions on search results. They don't do it all the time, but some of the time they will. It'd be pretty ugly seeing a search result that consisted of a description with hyphenated words.

 

You'd be better off giving each of your pages a unique and well written (yet still short) description and Google will love you. :)

Link to comment
Share on other sites

The same would apply doubledee, there would be no benefit (probably more of a bad thing if anything) from doing that. Google does use the description meta tag for page descriptions on search results. They don't do it all the time, but some of the time they will. It'd be pretty ugly seeing a search result that consisted of a description with hyphenated words.

 

You'd be better off giving each of your pages a unique and well written (yet still short) description and Google will love you. :)

 

Okay, good point!  (Sorry, been low on sleep!!)

 

 

Debbie

 

 

Link to comment
Share on other sites

With description, it should be whatever text provides a summary of the content for that page.  Many times, google will display what you have in your Description in their search results. 

 

Url's don't factor into it.  So in your examples above, example #1 would be the closest.  The google blog is often a good source for some information on how they look at it:  http://googlewebmastercentral.blogspot.com/2007/09/improve-snippets-with-meta-description.html

Link to comment
Share on other sites

With description, it should be whatever text provides a summary of the content for that page.  Many times, google will display what you have in your Description in their search results. 

 

Url's don't factor into it.  So in your examples above, example #1 would be the closest.  The google blog is often a good source for some information on how they look at it:  http://googlewebmastercentral.blogspot.com/2007/09/improve-snippets-with-meta-description.html

 

Thanks for the link.

 

All stuff I already *strive* to do.  8)

 

Thanks,

 

 

Debbie

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.