December 9, 2015

Make Blogger Nofollow Link With Javascript

nofollow link with javascript
Nofollow link mean tell search engine do not follow the link, I has been post about make automatic nofollow link for blogger and explanation what is nofollow and dofollow link, you can read on this post: http://myblog-note.blogspot.com/2014/03/make-blogger-nofollow-link.html.

But in this article I post another way to create nofollow link with javascript syntax, there are some argument what is the best, make nofollow link manual, or make it automatic for all external link inside your blog or website, for me, I think better make this automatic for all external link, because this for external not internal, so search will take little time and focus when crawl my site - CMIIW ;d).

On my post before, I post 2 way how to do this, one from dashboard setting, and the other one with Jquery syntax, now you only need to put this code below above </head>.

Login to you Blogger dashboard, click Template, and click Edit HTML, scroll down to find </head> or simply press ctrl-f and seacrh for </head>, paste this code above it:

<script type="text/javascript">
    var a = $(this);
    var href = a.attr('href');
    $(document).ready(function() {

      $("a[href^='http://']").each(function () {
         if(this.href.indexOf(location.hostname) == -1) {
            $(this).attr('target', '_blank');
    $(this).attr('title', 'Open in a new window');
            $(this).attr('rel', 'nofollow');
          }
        }
      );
    $("a[href^='https://']").each(function () {
    if(this.href.indexOf(location.hostname) == -1) {
            $(this).attr('target', '_blank');
    $(this).attr('title', 'Open in a new window');
            $(this).attr('rel', 'nofollow');
    }
    }
    );    
    });
</script>

Don't forget to click SAVE TEMPLATE.

Now you can test by give your blog one external link and preview it to make sure the code is running, and it also run with your website, just put it before </head>, usually inside your header.


You can also read this technique from the source: http://www.thewildblogger.com/2013/12/automatically-add-rel-nofollow-attribute-in-blogger.html

That's it, Thank you


You might want to see other posts:

No comments:

Post a Comment