How to Add Comments to a Blog Post

Gigatrees includes a comments area at the end of every blog post. By default, the comments area is empty, and hidden from view. To add comments you will first need to configure an external service to use it. Whichever service you use will need to write their contents to to an empty <div> with the id, disqus_thread. The name of this id is required by Disqus, but presumably other services could use the same id. is a free commenting system that is easy to setup and use. You will need to obtain a service id from their website. The service id will be include on the pages source code, so make sure you restrict its use to your domain before publishing it. Once you've obtained a service id, then it is easy to setup the required script. The first step is to copy the following code into your configuration. You will need to replace the the contents of the $DISQUSID$ with the service id you obtained from the Disqus website. The $DISQUS_STYLES$ placeholder enables the hidden comments section. The $DISQUS_SCRIPTS$ uses the service id you've defined and internal page placeholders to fill in the required fields.

  <Placeholders>
  
    <Placeholder> 
      <Name> $DISQUSID$ </Name> 
      <Content> [SERVICE_ID] </Content> 
    </Placeholder>
    
    <Placeholder> 
      <Name> $DISQUS_STYLES$ </Name> 
      <Content><![CDATA[ <style>#comments {display:inherit;}</style> ]]></Content> 
    </Placeholder>
    
    <Placeholder> 
      <Name> $DISQUS_SCRIPTS$ </Name> 
      <Content><![CDATA[ 
        <script>
          var pageId = "%PageId%";
          var disqusId = "$DISQUSID$";
          if (pageId && (pageId.length > 0) && disqusId && (disqusId.length > 0)) {
            var disqus_shortname = disqusId;
            var disqus_identifier = pageId;
            var disqus_title = "%PageTitle%";
            var disqus_url = "%PageURL%#comments";
            (function() {
              var dsq = document.createElement("script"); 
              dsq.type = "text/javascript"; 
              dsq.async = true;
              dsq.src = "//" + disqus_shortname + ".disqus.com/embed.js";
              (document.getElementsByTagName("head")[0] || document.getElementsByTagName("body")[0]).appendChild(dsq);
            })();
          }
        </script>
      ]]></Content> 
    </Placeholder>
	
  </Placeholders>

Once you've copied the placeholders to your configuration, then you will need to copy the following code into every blog post configuration where you want the comments to be enabled.

  <StyleOverrides>  $DISQUS_STYLES$  </StyleOverrides>
  <ScriptOverrides> $DISQUS_SCRIPTS$ </ScriptOverrides>

As you can see it is relatively simple to add a comments area to select blog posts where you want to allow your visitors to provide feedback or ask questions.

Comments