How To Manually Add Disqus Comment Widget to Blogger?


Disqus


In a previous post, we talked about integrating Disqus comments in a Blogger blog. That is just one of the ways to add this commenting system to your blog. If you're the geeky type, you'd want to do it manually, just so you know you can control it and customize it to your liking. It can also come in useful when the Disqus gadget installer isn't working. So today, we'll look at a manual way of installing the Disqus commenting system on your blogger blog.



Note that this method requires you to edit your blog's template HTML, so it is advisable to back up your template before continuing. Also, this method won't work on Blogger Dynamic Views templates.


Adding Disqus comments manually



  • From your Blogger dashboard, go to Layout, and then click on Add a gadget in the sidebar

  • Select the HTML/JavaScript widget from the list



Add a widget


  • Enter Disqus as the title and the following in the content;




<!-- Disqus comments gadget -->



We've added a new widget. It is time to tweak it a bit.


  • Now go to the Template section, and go into the Edit HTML mode

  • Find the widget you just created by searching for 'Disqus'. You should see something like this;



<b:widget id='HTML1' locked='false' title='Disqus' type='HTML'>


  • Add a mobile='yes' key-value pair in that line. It will now look like this;



<b:widget mobile='yes' id='HTML1' locked='false' title='Disqus' type='HTML'>


  • Now delete the following code before the closing widget tag...




<b:includable id='main'>

  <!-- only display title if it's non-empty -->

  <b:if cond='data:title != &quot;&quot;'>

    <h2 class='title'><data:title/></h2>

  </b:if>

  <div class='widget-content'>

    <data:content/>

  </div>

  <b:include name='quickedit'/>

</b:includable>



  • ...and replace it with the following code;




<b:includable id='main'>

            <script type='text/javascript'>

                var disqus_shortname = &#39;CHANGETHIS&#39;;

                var disqus_blogger_current_url = &quot;<data:blog.canonicalUrl/>&quot;;

                if (!disqus_blogger_current_url.length) {

                    disqus_blogger_current_url = &quot;<data:blog.url/>&quot;;

                }

                var disqus_blogger_homepage_url = &quot;<data:blog.homepageUrl/>&quot;;

                var disqus_blogger_canonical_homepage_url = &quot;<data:blog.canonicalHomepageUrl/>&quot;;

            </script>

            <b:if cond='data:blog.pageType == &quot;item&quot;'>

                <style type='text/css'>

                    #comments {display:none;}

                </style>

                <script type='text/javascript'>

                    (function() {

                        var bloggerjs = document.createElement(&#39;script&#39;);

                        bloggerjs.type = &#39;text/javascript&#39;;

                        bloggerjs.async = true;

                        bloggerjs.src = &#39;//&#39;+disqus_shortname+&#39;.disqus.com/blogger_item.js&#39;;

                        (document.getElementsByTagName(&#39;head&#39;)[0] || document.getElementsByTagName(&#39;body&#39;)[0]).appendChild(bloggerjs);

                    })();

                </script>

            </b:if>

                <style type='text/css'>

                    .post-comment-link { visibility: hidden; }

                </style>

                <script type='text/javascript'>

                (function() {

                    var bloggerjs = document.createElement(&#39;script&#39;);

                    bloggerjs.type = &#39;text/javascript&#39;;

                    bloggerjs.async = true;

                    bloggerjs.src = &#39;http://&#39;+disqus_shortname+&#39;.disqus.com/blogger_index.js&#39;;

                    (document.getElementsByTagName(&#39;head&#39;)[0] || document.getElementsByTagName(&#39;body&#39;)[0]).appendChild(bloggerjs);

                })();

            </script>

</b:includable>



  • In the code above, change the text CHANGETHIS to your own forum shortname, e.g. MyBloggerTricks.



You now have Disqus installed on your Blogger blog! You can now the widget to you liking!

Related Posts:

  • How To Disable Lightbox View For Blogger Images?Update: Lightbox Effect is Offcially Disabled by Blogger. No Worries now. Try a more correct wayBlogger just announced today that they have now automatically added Lightbox view effect to all blogs by default. Now when you cl… Read More
  • 1000+ Background Patterns For Blogger Comment Box!Whether you like flowers, Christmas, EID, Greenery or Dark and light backgrounds then thankfully now you give any color and look to your blogger comment forms. The code that we previously released can be used to give any back… Read More
  • Should you Enable Blogger Dynamic Views? Blogger has now officially introduced Dynamic views for all blogs by default. Now you can change the layout of your custom template into different shapes. A dynamic view is an automated code that rearranges your div areas a… Read More
  • Disable Lightbox View The Correct wayUpdate: Lightbox Effect is Offcially Disabled by Blogger. No Worries now.Yesterday I shared a short code that somehow helped to deactivate and remove the lightbox view for images appearing on blogger blogs. However some of th… Read More
  • Open Multiple Webpages Using a single LinkI have been using a simple JavaScript call function to open multiple sites on a single click. This function declares several URL’s in its body and once the function is called either through a hyperlink or an image, the click … Read More