Skip to content

Instantly share code, notes, and snippets.

@opistola
Created November 30, 2012 12:38
Show Gist options
  • Save opistola/4175526 to your computer and use it in GitHub Desktop.
Save opistola/4175526 to your computer and use it in GitHub Desktop.
Jquery script to add rel="nofollow" to all likes besides the current domain
$('a').each(function()
{
var reg_exp = new RegExp('/' + window.location.host + '/');
if (!reg_exp.test(this.href))
{
// External Link Found
$(this).attr('rel','nofollow');
}
});
@p47ri0t
Copy link

p47ri0t commented Apr 24, 2018

hi
how can i set rel nofollow for custom link ?

i want no follow just site.com

@gloarb
Copy link

gloarb commented Jun 8, 2018

var reg_exp = new RegExp('site.com');
$('a').each(function()
{

		   if (!reg_exp.test(this.href))
		   {
		     // External Link Found  
		     $(this).attr('rel','nofollow');
		   }
		});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment