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

Matt Cutts states in this video:

It turns out that as we are executing JavaScript, we do look at the attributes. So you can actually use Javascript and put, like, a nofollow attribute on individual URLs.

I'm not clear to me what the syntax for that would be. How would I put a nofollow on a link in a variable like this?

var mylink = "http://example.com/";

or if it in AJAX like this?

$.ajax({
    type: 'post',
    url: '/path/ajax-handler/' + method,
    success: function(data) ...
share|improve this question

2 Answers 2

What he is referring to is the HTML markup of the page. The nofollow keyword goes into a rel attribute on a tag, usually an <a> tag with an href like so: <a href="/link" rel="nofollow">link</a>. So he is suggesting that if you don't want search engines parsing through your javascript and looking for links you can do this:

<script rel="nofollow" src="/js/code.js"></script>
share|improve this answer
    
I hadn't considered that. That would be decidedly less useful than I was hoping. –  Stephen Ostermiller Mar 28 '13 at 16:42

There is no attribute "rel" in <script>, therefore the following code will produce a validation error in your CSS:

<script rel="nofollow" src="/js/code.js"></script>

Does Google follow JavaScript links? Yes. http://www.adherewebdesign.com/experiment/results/

Possible solution: Edit robots.txt to include the following line:

User-agent: * Disallow: http://offending-java-url.com

This will stop all bots from following the java link.

Also, You can verify your CSS validation here: http://validator.w3.org/

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.