tags:

views:

317

answers:

5

Currently our website uses links to allow the user to change their locale. The problem with this is that you get a lot of random outlinks from each page on the site to... the same page, in other languages. When a search engine traverses this, it gets an excessively complex view of the site.

We were going to change it to a form post to avoid this. However, it seems to me that we should just be able to change it to an onclick="window.location.href='change_my_language.php'" rather than an href="change_my_language.php". Am I right? Or do the major search engines scan for and follow this sort of thing nowadays?

A: 

I'm fairly certain search engines don't parse JavaScript, so any code that changes the value of any property of the location object wouldn't follow the URL.

EDIT
An interesting article on the topic: http://www.seroundtable.com/archives/019026.html

and bobince's answer on this potential duplicate question suggests the same: http://stackoverflow.com/questions/1486034/window-location-and-seo/1486461#1486461

Andy E
[Google might parse javascript links](http://www.seomoz.org/ugc/new-reality-google-follows-links-in-javascript-4930)
David Murdoch
@David Murdoch: Date of your article Aug 7th 2008, date of article I linked to is Dec 19th 2008. The article suggests that someone from Google confirmed that Google doesn't follow URLs in JavaScript.
Andy E
A: 

Google is getting increaingly better at parsing javascript. I don't think that the search engines will follow this link now...but to be more certain they don't follow you can change your anchor tags to spans instead and use the onclick="document.location='url'" method.

Though what you may want to do is add rel="nofollow" to these links instead. You can also add a canonical link to the main page.

David Murdoch
`span` tags should never be used for links just to trick search engines. Ewwww. There is always a good way to do something without sacrificing an HTML document's semantic value.
Matchu
@Matchu, exactly what sort of "sacrifice" is being made by changing a link to a span tag consider the OP doesn't care about whether or not javascript is enabled?
David Murdoch
Semantic value. Something that is quite clearly a link should not be marked as a `<span>` unless you want to put in all sorts of extra work: style them into default link appearance, have to explain to confused future developers why you did something so ridiculous, etc., not to mention that you entirely lose standard browser link handling, which means no tabbing, screen readers will miss them entirely, etc. Just because something will work for most viewers doesn't mean that it's good practice, and there is *always* a good way of solving any problem. This will just make you look like an amateur.
Matchu
Not to mention that I don't get your question. If the OP doesn't care if Javascript is enabled (which I don't see him indicate anywhere), then we shouldn't be introducing Javascript dependencies that require him to care, right?
Matchu
OP said: "it seems to me that we should just be able to change it to an onclick="window.location.href='change_my_language.php'" rather than an href="change_my_language.php" - so it looks like javascript doesn't matter to OP. thats all.
David Murdoch
+1  A: 

To solve the larger problem of duplicate content, you can use the canonical link tag to specify on the pages in other languages the URL of the preferred document.

<!-- on http://www.example.com/article.php?id=123&amp;language=something-else -->
<link rel="canonical" href="http://www.example.com/article.php?id=123" />

To save search engines the trouble of landing on the other pages, it wouldn't hurt to add rel="nofollow" to the links, to ensure that robots don't waste their time checking them out. However, the canonical link tag is still vital, in case someone links to your other-language content, to ensure that your preferred page gets the ranking credit.

Matchu
A: 

POST method must be used when the request changes server's state, i.e. request has side-effects:

http://www.cs.tut.fi/~jkorpela/forms/methods.html

No, search engines won't be able to follow javascript links, but POST is more elegant solution.

jholster
A: 

When a search engine traverses this, it gets an excessively complex view of the site.

This should not be a problem. As long as you are correctly marking up each page with lang="...", the search engine should know what to do with it. What is the actual problem you are facing that leads you to believe search engines are confused by a ‘complex’ link map?

You can give them a sitemap if you really want to be explicit.

However, it seems to me that we should just be able to change it to an onclick="window.location.href='change_my_language.php'" rather than an href="change_my_language.php"

That would degrade the site's usability and accessibility a little as well as (deliberately) sabotaging the search engine.

In any case, whatever you do you should definitely leave each language version on its own URL (eg. /en/category/title) rather than totally relying on a language-setting cookie, or you really do run the risk of confusing search engines. Normally you do want search engines to index every language version you have, to catch searches from users of other languages.

bobince