Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

We have support for various languages in our website, including Spanish, French and Swedish.

For now, the links in the site are NOT encoded before sent to the browser, sending the real accented chars (if such exists, i.e. href="www.(dot)example(dot)com/héllo.html") and not their HEX representation.

This works & looks good on all browsers, including Chrome, FF and IE.

However, we care great deal about SEO.

We got this tip that encoding the links before sending them to the browser (so instead of linking to http://www.example.com/héllo, we will link to http://www.example.com/h%E9llo) will improve the way search engines will 'understand' the links and the keywords in the URL.

This involves some work at our side, so we wanted to know if there's truth in that tip, but couldn't find anything addressing this issue.

share|improve this question

migrated from stackoverflow.com Dec 9 '11 at 3:30

This question came from our site for professional and enthusiast programmers.

    
This question might be relevant. From info there, I get the feeling that when you type (or click on a link with) an unencoded URL, the browser will encode it into an ASCII URL before sending it to the server--which would make both URLs you wrote the same. But I'll have to test this out later as I'm not too sure. –  Lèse majesté Dec 9 '11 at 4:36
add comment

1 Answer 1

up vote 6 down vote accepted

According to Google:

Yes, we can generally keep up with UTF-8 encoded URLs and we’ll generally show them to users in our search results (but link to your server with the URLs properly escaped). I would recommend that you also use escaped URLs in your links, to make sure that your site is compatible with older browsers that don’t understand straight UTF-8 URLs.

So encoding your URLs seems like it would be search engine friendly. But your best bet may be to just remove those special characters and replace them with the "non-special" alternatives. This StackOverflow answer shows some awesome code for doing that:

Try these functions:

<?php
function Slug($string, $slug = '-', $extra = null)
{
  return strtolower(trim(preg_replace('~[^0-9a-z' . preg_quote($extra, '~') . ']+~i', $slug, Unaccent($string)), $slug));
}

function Unaccent($string)
{
  return html_entity_decode(preg_replace('~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i', '$1', htmlentities($string, ENT_QUOTES, 'UTF-8')), ENT_QUOTES, 'UTF-8');
}
?>

And use it like this:

<?php 
echo Slug('Iñtërnâtiônàlizætiøn of Glaño'); // internationalizaetion-of-glano
?> 

You can embed the Unaccent() code into the Slug() function if you wish to have only one function.

share|improve this answer
    
Thank you. Though it is simple to strip those special chars, we would like to keep them. The thread you linked to was a big help. –  Dan Dec 11 '11 at 11:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.