Sometimes you want link a specific keyword in your blogger posts to a perfect targeted post that might get some awesome exposure and side by side provide some useful knowledge to all your readers but editing every single post is a nightmare and you do not have much time and stamina to do that if you have a whooping 1000+ posts on your blog. Well but if that thing gets automatic using javascript it would be a life saver, isn't it.
Well I found a useful script like I have earlier posted few awesome one's for redirecting your 404 links to homepage and even removing all links from your blogger comments. Well this script allows you to mark a specific keyword and even link it up with any post from your blog. So you have a free option to choose that keyword and even choose the post you want to link it too.- Open
Blogger > Template > Edit HTML. - Press
Ctrl +F & search for</body>
tag & paste below code above it.<script src='//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'/>
<script type="text/javascript">
function autoLink(){
this.keywdHref = new Object();
this.add = function(keyword, href){
if(keyword.substr(0,1) != " "){keyword = " " + keyword;}
this.keywdHref[keyword] = href;
}
this.createAnchor = function(){
var objs = document.getElementsByTagName("div");
for(var i=0; i<objs.length; i++){
var obj = objs[i];
if(obj.className.indexOf("post-body")>-1){
var content = obj.innerHTML;
for(var keyword in this.keywdHref){
var href = this.keywdHref[keyword];
var newstr = content.replace(keyword, "<a href='"+href+"'>"+keyword+"</a>", "gi");
obj.innerHTML = newstr;
content = newstr;
}
}
}
}
this.startScript = function(){
var onLoad = window.onload;
window.onload = function(){
if(onLoad){onLoad();}
setTimeout("f.createAnchor()", 100);
}
}
}
</script><script type="text/javascript">
var f = new autoLink();
f.add("KEYWORD", "http://www.hackinguniversity.in/");
f.startScript();
</script> - Now just change the text in blue with your Keyword.
- And change the red text with your blog post URL.
- Now after making all these changes just press save template & refresh your blog.
- So now just check any of your post with that Keyword and see how that keyword will be linked up to that post you have mentioned above.
So that ends this another awesome tutorial briefing you how to easily link a specific keyword in your blogger posts automatically using javascript. So just enjoy this script and do comment if you face any problem using this script.
(COMMENTS WILL LOAD AUTOMATICALLY)