How To Automatically Open External Links in a New Page And Set The Nofollow Tag

External links One of the inevitable components of blogging is to explain or download a file but there are two problems associated with external links :

  • Open the link in blog window and this makes the visitor leave the blog and may still be reading
  • External links become Dofollow which negatively affects the blog that has its most presence
Of course, there is a manual way to make external links open in a new page, which is to be given the Nofollow tag An example of a link will open in a new page with a Nofollow tag :
<a href='#' target="_blank" rel="nofollow">Example</a>

The Blue means that the link will be open in a new window and The Red is Nofollow Tag.

The manual method is the best, you do not need to install the codes.But there are those who did not know those things and his blog is full of links and can not modify them all, So The solution is to put this code in your Template:

Step 1: Go To Blogger.com >> Template >> Edit Template
search for the </body> tag and copy paste the code bellow before it
<script type='text/javascript'>
$(document).ready(function() {
$("a[href^='http://']").each(
function(){
if(this.href.indexOf(location.hostname) == -1) {
$(this).attr('target', '_blank');
$(this).attr('rel', 'nofollow');
}
}
);
$("a[href^='https://']").each(
function(){
if(this.href.indexOf(location.hostname) == -1) {
$(this).attr('target', '_blank');
}
}
);
});
</script>
That's All, i wish that i help you *_*.