Ability to add rel="nofollow" to links within the CMS Editor on Rich Text Fields - Up your SEO Game

Easy way to do this…

Add #nofollow at the end of the link.

So your link should look like this:

Some text

Then add this script in:

$(“a”).each(function() {
var url = ($(this).attr(‘href’))
if(url.includes(‘nofollow’)){
$(this).attr( “rel”, “nofollow” );
}else{
$(this).attr(‘rel’,‘dofollow’)
}
console.log($(‘body’).html())
})

This script will search each link to see if it contains the “nofollow” text, and add it in as a rel=“nofollow” throughout the site. Otherwise if this #nofollow doesn’t exist it will add a rel=“dofollow”

Oh…and if you want to hide the nofollow from the url, you add this:

$(this).attr( “href”,$(this).attr( “href”).replace(‘#nofollow’,‘’))
$(this).attr( “href”,$(this).attr( “href”).replace(‘#dofollow’,‘’))

3 Likes