Ghost Platform - Update links for nofollow and target blank

When using the Ghost platform, you will run into the issue of links being as they are: (a href="mylink.com")mylink.com(/a) (< and > changed to give you a sample.

What we want is:
href="mylink.com" target="_blank" rel="nofollow"

Simply add this code to your header injection:

script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'
/script

Don't forget to add the < and > tags back.

Wrap this code in script tags:


$(document).ready(function() {
$("a[href^=http]").each(function(){
var excluded = [
// format for whitelist: 'google.com', 'apple.com', 'myawesomeblog.com'
// add your excluded domains here
];
for(i=0; iif(this.href.indexOf(excluded) != -1) {
return true;
}
}
if(this.href.indexOf(location.hostname) == -1) {
$(this).click(function() { return true; });
$(this).attr({
target: "_blank",
rel: "nofollow"
});
$(this).click();
}
})
});


And after that, click save and your links will now open in new windows and also receive a nofollow attribute.

Source: https://github.com/shockey/ghost-external-links/blob/master/ghost-external-links.js