This code will add a nofollow attribute to external pages on your website

Last updated on May 4th, 2018 at 01:43 am

I found out that Spammers has turned one my website into their hub. So, I came up with this code to discourage them from posting on my site and also remain on the good side of Google. The code will automatically attribute a rel=”nofollow” to all the external anchor tags on your website.

A reliable hosting company which I highly recommend and use for Wordpress, Oxwall and Skadate hosting is currently giving out more than 50% discount, including VPS and shared hosting. This might be your last chance to host with a2hosting.
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js' type='text/javascript'></script>
<script type='text/javascript'>
$(document).ready(function(){ $("a[href^='http://']").each(
	function(){
		if(this.href.indexOf(location.hostname) == -1) {
			$(this).attr('rel', 'nofollow');
		}
	});
	$("a[href^='https://']").each( function(){
		if(this.href.indexOf(location.hostname) == -1) {
			$(this).attr('rel', 'nofollow');
		}
	});
});
</script>

Simply paste the code on the <head></head> section of your website.

Premium Service

If you seek a custom feature developed for your website or need 24/7 premium support to help you get started with your social network or Skadate dating website, save hours of searching online or wasting money on unnecessary plugins, get in touch with me and let's discuss a suitable plan for your project. Best thing about this service is that you are never placed on hold and get to talk to an expereinced Oxwall/Skadate developer.

Get in Touch

Leave a Reply