USING HASHOVER COMMENTS SYSTEM FOR HUGO STATIC WEBSITE


Motivation:

As an initial approach, the Disqus commenting platform was used on this site. Disqus is nicely integrated in Hugo and so getting this service up and running a static site is no big deal.

(Hugo is a static site generator which allows you to create web sites completely independently of any web service and off-line on your local computer).

Although after a while of usage (and very little comment activity), I felt I need to replace Disqus for various reasons. Ideally a commenting system should be open source, easy to install, self-hosted and I also would like to use sqlite as database backend.

After searching for quite a while in the web for such a candidate, I stumbled upon HashOver. (Hashover did not even claim to have support for sqlite but in the lates release 2.0 there is!)

Hashover is …

  • .. a free and open source PHP comment system, find more information here: http://tildehash.com/?page=hashover
  • … a self-hosted system and allows completely anonymous comments to be posted, the only required information is the comment itself.

HashOver - installation in brief:

The following is more or less a cheat sheet for me to remember the steps required to get HashOver installed.

To install an add-on software, I usually create a sub-domain with a dedicated directory. This allows me to organize the directory structure on the server as I want to. No need to create any re-directions on the web server, no need to mess around with apache’s .htaccess file.

To install HashOver on a sub-domain the following step are required so far:

  • create a sub-domain on the provider’s portal e.g. like

        sub domain-name: cmd.my-domain-name.domain
        directory:       /my-domain-name.domain/cmd
    
  • download the HashOver software from github and copy it with ftp (filezilla) onto the webserver

    the web server directory might look like:

        /my-domain-name.domain/cmd/hashover
    

    Note: There is a version 2 available already, so I opted for this new release.

  • once done, the following files need to be edited and configured as described in the docmentation

    • /my-domain-name.domain/cmd/hashover/backend/classes/secrets.php
    • /my-domain-name.domain/cmd/hashover/backend/classes/sensitivesettings.php

    Please note that in the sensitivesettings.php the hostname of the sub-domain needs to be entered otherwise HashOver will throw an error saying: hashover external use not allowed

  • once done, HashOver’s admin panel should be already fully functional, go to the url to test:

    cmd.my-domain-name.domain/hashover/admin

  • but wait - latest PHP version needs to be enabled on the provider’s site which for the moment is PHP 7.X.X stable.

Hugo site configurations:

To enable commands on each individual blog page is pretty straightforward:

  • head.html:

    Found out that since the latest version 2 this is not required/valid anymore:

    <!-- hashover -->
    <link href="http://cmd.my-domain-name.domain/hashover/comments.css"
          rel="stylesheet" type="text/css">
    
  • single.html

    To initialize the comments system, place the following code whereever it’s suitable.

        <!-- page comments -->
        {{ if not (in (.Site.BaseURL | string) "localhost") }}
    
            <div id="hashover"></div>
    
            <!-- load asynchronous -->
            <script type="text/javascript">
                (function() {
                    var s = document.createElement('script'),
                    t = document.getElementsByTagName('script')[0];
                    s.type = 'text/javascript'; s.async = true;
                    s.src = src="http://cmd.my-domain-name.domain/hashover/comments.php";
                    t.parentNode.insertBefore(s, t); })();
            </script>
    			
        {{ else }}
            <h2 style="color:Orange;"> Comments will appear here! </h2>
        {{ end }}
    
    

At this stage the comments should be fully operational. O.k. not locally, while developing and editing the static site, but on the web-server after transfering the site onto the provider’s web-space.

Admin Panel:

The admin panel can be reached via the site’s address e.g. like:

http://cmd.my-domain-name.domain/admin/login

Known Problems:

  • If cookies are disabled, is is not possible any more to login as admin. So, for the moment, cookies must be enabled.

    Settings are managed by the following JSON file: /hashover/config/settings.json

  • Comments are not shown on outdated browsers and javascript must be enabled.

  • Problem with notification e-mail (if any), there are no e-mail delivered whatsoever. Need to figure this out as I cannot response in short term to a comment.