3

If I use JavaScript + jQuery, for example, does links inserted in $(document).ready() will be available for crawling? How can I insert crawlable links in JavaScript?

2 Answers 2

5

No, links inserted with Javascript will not be crawlable. You are better using a server-side solution to add links, i.e. output <a href="link">etc</a> direct in your HTML.

Having said that, search engines are always improving. Google recently announced major improvements to the crawling of Flash files, so it's not impossible that some Javascript links could be crawled. It does depend on the situation. Something simple like onclick="window.location='http://etc'" would probably be fine.

There is probably a better way to do what you are doing. If you provide more details (i.e. why you are using Javascript to add links), we may be able to offer better guidance. Perhaps you can output links in a hidden layer, and show them when needed? That way the links are in the raw HTML and will be crawled.

2
  • wouldn't Google think hiding the links as cloacking? Commented Jan 1, 2011 at 3:36
  • 1
    @Rad: Google have stated before not to worry about things like that. They know there are legitimate cases for hiding links so as long as you are not spamming i.e. there is a mechanism to show the hidden links, there shouldn't be a problem. Commented Jan 1, 2011 at 12:18
1

I use progressive enhancement so have the link in there in as a tags in the HTML which is then over ridden by the JavaScript. I suppose its also good for users that have JavaScript turned off (although I'm not really sure if people even do that any more.)

<ul>
<li><a href="index.html" id="show-services" >Our services</a></li>
<li><a href="about-us.html" id="show-about">About us</a></li>
</ul>

and then attach the AJAX content to the a tag ids

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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