Automatically Add rel="nofollow" Attribute To External Links in Blogger!

This weekend i decided to publish tutorials that will analyze critical problems issues in blogger and fix the errors simply in the SEO friendly way. So today we'd discuss about external links and how to automatically append rel='nofollow', target='_blank' and a simple title='Open link with new window' attributes to all the external links with the help of JavaScript. Amongst these attributes rel='nofollow' is one of the most important concerns when this code first used instead of transferring robots into a blocked URL to signify external links from a page. Really this tag plays a great role when you don't know how to add external links with your post whether robots index all the available links from your pages also mark URLs that include rel='nofollow' attribute except your internal links. 

add rel="nofollow" attribute to blogger

This will help robots to index all the links internally nevertheless you wish to send traffic to other sites so it will not hamper your SEO settings anymore. Let's see how to do it for blogger and other platform.
1) Source code is written by Programming Geeks of MBT
2) Further the script developed by Ahmed

Automatically Include rel="nofollow", target="_blank" to Blogger External Links

1. Go to Blogger → Template
2. Backup Your Template
3. Click on Edit HTML
4. Now search for the following code
</head>
5. Just above </head> simply paste the following code
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js' type='text/javascript'></script>

    <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', 'Click to 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', 'Click to open in a new window');
            $(this).attr('rel', 'nofollow');
    }
    }
    );
    
    });

    </script>
PS: Please do not add the light blue code if you already have jQuery library source code installed on your blog.

6. Finally save your template and you're almost done!

Test The Functionality Of This Powerful Snippet!

Adding this snippet will start working on all the anchor texts/hyperlinks of your entire blog and scans to match each link either equal to (== -1) or (== 1). Hence the script scans values inside href attributes and if the value is equal to a negative one (== -1), then it sorts out the hostname is an external domain. 

Finally it includes three tags on each external link [rel="nofollow", target="_blank" and title="Click to open with new window"] so humans who will browse your pages will get external links opened with new window also an appended title. But for robots they will also get the links with rel="nofollow" which our objective to feed all the external links of our pages to robots with rel="nofollow" attribute.

So you need not manually add rel="nofollow" also target="_blank" attributes with each external link when posting. Below we attached some images with documentations

External Links With 3 Important SEO Attributes

Automatically Added Attributes With External Links

Rather All Internal Links Are Safe and Secured

Internal links Are Safe and Secured

How To Optimize The Script For Internal Links?

The snippet is fully integrated with Blogger, WordPress and other basic HTML websites. In WordPress you can add the snippet making a JavaScript link and installing in function.php file or read below tutorials
In this snippet you can find a yellow highlighted code says
if(this.href.indexOf(location.hostname) == -1)
we told the functionality of this minus value but if you change the value to == 1 then it will play alternatively which means it will include these three tags on all the internal links of your blog (that will seriously play wrong SEO for your blog). You can do but removing this line from the scipt
$(this).attr('rel', 'nofollow');

Does This Snippet SEO Friendly?

Of course the function of this snippet is fully SEO controlled on external links, again it reduces your extra labors to manually adding rel and target attributes with external links. Also the snippet works with Chrome, Firefox,  IE8 and Upgrade and other major browsers including mobile devices.

Hope this tutorial helped you to know something about the significance of external hyperlinks and adding SEO attributes for signifying robots to stop indexing external links.

Any type of question regarded this tutorial is welcome :)

3 comments

  1. thanks for this. If you would be so kind please have a look on my page and if possible to give me some advise to make it better. I'm really having trouble getting approval from adsense.

    thanks again,

    ReplyDelete
  2. I forgot to put my page on my recent comment.
    here it is btw.

    http://android-dtechtive.blogspot.com
    and
    http://resortsbook.blospot.com

    ReplyDelete
  3. http://detayara.blogspot.com thanks.

    ReplyDelete

About

The Wild Blogger is a technology blog which covers all popular and trending news of the web, tech tutorials, blog, blogging tips and tutorials, seo tips, social media marketing, content marketing and tools. Read More...

Browse by Topics

SEO Social Media Make Money

Blogger Tricks Tutorials

Blogging Tips Photoshop