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

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?

share|improve this question

2 Answers 2

up vote 5 down vote accepted

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.

share|improve this answer
    
wouldn't Google think hiding the links as cloacking? –  CamelCamelCamel Jan 1 '11 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. –  DisgruntledGoat Jan 1 '11 at 12:18

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

share|improve this answer

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.