How To Add Related Articles To Middle Of Blogger Blog Post

How To Add Related Articles To Middle Of Blogger Blog Post

After creating a new blog on Blogger, we write good posts (articles) in it. And when our blog gets old and the number of posts in it increases, then we think we should add a link to another article in all the posts. And it is also very important.

When we are new in blogger, we do not know much. How to do that. But slowly working on the blogger and if we understand it well then we can learn everything. And you can add everything on your blog that is beneficial for our website, its posts and its readers.

So in this post today, we will know how to automatically add a link to another post in any blog post and what are its benefits.

Benefits of adding a link to an old post in every blog post :-

To make your website at the top level, the blogger makes every effort which is necessary and one of these is to add a link to other posts in every post. When a visitor comes to your blog and reads your post, then in the middle of that post there is a link to the post related to that post, then visitors will like any of those posts. So he will definitely click on that link and will definitely read your post as well. This will increase the pageviews of your blog and with this the reader will spend a lot of time on your site. With which the bounce rate of your site will also be good and the ranking of the blog will also be good.

How To Add Related Articles To Middle Of Blogger Blog Post

  • Login to your blogger blog Dashboard.
  • Then go to Theme > > Edit HTML.
  • Click anywhere inside the code area and press Ctrl + F keys to open the search box.
  • Now, Search for ]]></b:skin> tag and paste below code just above of this tag.

/*Articles Related to Middle of Posts*/
.Tggyan{background:#FFF;position:relative;display:inline-block;border:2px solid #DDD;margin:22px 0}
.Tggyan h4{background:#FF3333;font-family:Poppins,sans-serif;color:#FFF;font-size:12px;font-weight:700;position:absolute;top:-0px;left:0%;padding:8px 18px;border:1px solid #DDD;border-radius:5px;text-transform:uppercase}
.Tggyan h4:before{content: '\f043';right: 10px;bottom: 0;font-family:FontAwesome;font-style: normal;font-weight: 400;margin: 0 5px 0 0;color: #fff;}
.Tggyan ul{padding:12px 12px 0;list-style:none}
.Tggyan ul a:before{font-family:fontawesome;content:'\25b6';padding-right:10px}
.Tggyan li{border-radius:5px;border-bottom:1px solid rgba(0,0,0,0.33);line-height:1.7em}
.Tggyan li:hover {text-decoration: underline;} 

  • Now, Search for <data:post.body/> tag and replace it with the below code.
Note :- If you see this code one or more times, Select the code that appears in the last.

<b:if cond='data:blog.pageType == &quot;item&quot;'>
<script type='text/javascript'>
//<![CDATA[
// Articles Related to Middle of Posts
var Tggyan = new Array(); var TggyanNum = 0; var relatedUrls = new Array(); function related_results_labels(json) { for (var i = 0; i < json.feed.entry.length; i++) { var entry = json.feed.entry[i]; Tggyan[TggyanNum] = entry.title.$t; for (var k = 0; k < entry.link.length; k++) { if (entry.link[k].rel == 'alternate') {relatedUrls[TggyanNum] = entry.link[k].href; TggyanNum++; break;}}}} function removeRelatedDuplicates() { var tmp = new Array(0); var tmp2 = new Array(0); for(var i = 0; i < relatedUrls.length; i++) { if(!contains(tmp, relatedUrls[i])) { tmp.length += 1; tmp[tmp.length - 1] = relatedUrls[i]; tmp2.length += 1; tmp2[tmp2.length - 1] = Tggyan[i];}} Tggyan = tmp2; relatedUrls = tmp;} function contains(a, e) { for(var j = 0; j < a.length; j++) if (a[j]==e) return true; return false;} function printRelatedLabels() { var r = Math.floor((Tggyan.length - 1) * Math.random()); var i = 0; document.write('<ul>'); while (i < Tggyan.length && i < 20) { document.write('<li><a href="' + relatedUrls[r] + '">' + Tggyan[r] + '</a></li>'); if (r < Tggyan.length - 1) { r++; } else { r = 0;} i++;} document.write('</ul>');}
//]]>
</script>
</b:if>
<div expr:id='&quot;post1&quot; + data:post.id'/>
         <div class='Tggyan'>
            <b:if cond='data:post.labels'>
            <b:loop values='data:post.labels' var='label'>
            <b:if cond='data:blog.pageType == &quot;item&quot;'>
               <script expr:src='&quot;/feeds/posts/default/-/&quot; + data:label.name + &quot;?alt=json-in-script&amp;callback=related_results_labels&amp;max-results=3&quot;' type='text/javascript'/>
                  </b:if>
                  </b:loop>
                  </b:if>
                  <h4>Also Read</h4>
                  <script type='text/javascript'>
                  removeRelatedDuplicates();
                  printRelatedLabels();
               </script>
         </div>
         <div expr:id='&quot;post2&quot; + data:post.id'><p><data:post.body/></p></div>
         <script type='text/javascript'>
            var obj0=document.getElementById(&quot;post1<data:post.id/>&quot;);
            var obj1=document.getElementById(&quot;post2<data:post.id/>&quot;);
            var s=obj1.innerHTML;
            var t=s.substr(0,s.length/2);
            var r=t.lastIndexOf(&quot;&lt;br&gt;&quot;);
            if(r&gt;0) {obj0.innerHTML=s.substr(0,r);obj1.innerHTML=s.substr(r+4);}
         </script>

  • Click Save Theme.
ViewCloseComments
Cancel