Question

I have an HTML5 demo site (http://html5beats.com/) that uses JavaScript to detect certain HTML5 features. I do a redirect to a "please change or upgrade your browser" page if those features are not present, since they are critical to making the site work.

The problem is that some search engines (specifically Google) seem to follow the redirect. This results in a nasty "Your Browser is Not Supported" message as the main search result for my site.

Am I using JavaScript redirects incorrectly? Is there something I can do to tell Google and other search engines which page has the main site content?

Was it helpful?

Solution

First, you should use robots.txt to tell search engines those pages that you don't want listed:

Second, you can also provide assistance to Google (and other search engines) in understanding your site by providing a sitemap:

Third, you can also consider a quick-and-dirty method of catching the Google bot (and other web crawlers) through the navigator.userAgent property in JavaScript and preventing the redirect in those cases:

In the last case, don't do a direct comparison of the navigator.userAgent string. Rather, use indexOf to find the identifying URL in the user-agent string, e.g.:

function upgradeRedirect() {
 if (navigator.userAgent.indexOf("http://www.google.com/bot.html") != -1) return;
 document.location.href = 'upgrade.html';
}

OTHER TIPS

It really comes down to the content you are serving to Googlebot given the user-agent they are crawling with. Perhaps a better strategy would be to load your regular content with your regular title tag etc. and then pop a modal dialogue over the page if the user doesn't support html5 with some links to download an html5 browser. That way your listing will still look respectable for site:http://html5beats.com/. BTW -- I really like your site/idea.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top