Adding Comments To Ghost

Adding Comments To Ghost
Photo by Volodymyr Hryshchenko / Unsplash

Something I immediately noticed was Ghost’s lack of a comment system, which for me was a must have feature. So I started looking around for a solution and I am happy to say that I found one.

Comment widgets

Well first let's get an understanding of how these comment systems work. I expected that I would have to install a plugin to Ghost and it would add to the database schema whatever it would need to support comments. But that is not the case, instead an independent piece of software manages everything to do with the comments and all Ghost needs to do is include an external script.

During my research I came across a number of widgets, most of which did not meet my requirements. I wanted something I could install the docker compose that supported sign in with Google and anonymous comments.

Disqus
Supposedly it was full of ads so that was a no go.Additionally is that really awful one you see all the time with Facebook comments. If you see it you'll recognise it.

Discourse
Was often recommended, but it has an asinine installation process and was unnecessarily complicated for my use case.

Talkyard
Initially looked really good but then I looked into the installation instructions and again they were just stupid and unnecessarily complicated.

Commento
Unlike a couple of the others a simple Docker compose file is all that was required to get this running, and initially everything seemed well until I attempted to configure sign in with Google. For the most part it would work, unfortunately it was not able to load profile pictures. After hours of troubleshooting I eventually found out that it was a bug in Commento and unfortunately it appears that the project has been abandoned.

Commento++
Commento++ is a fork of Commento fixing all of the bugs and adding a couple new features. Conveniently it's perfectly compatible with the original Commento, so I simply needed to change the docker image to get it running.


Setting up Commento++ with Docker

My final Docker Compose file will contain both Ghost and Commento++ just to simplify things. But below is the Docker compose file I used for testing Commento++.

version: '3'
services:
  commento:
    image: caroga/commentoplusplus:v1.8.6
    restart: always
    ports:
      - 8080:8080
    environment:
      - COMMENTO_ORIGIN=https://<DOMAIN FOR commento>/
      - COMMENTO_PORT=8080
      - COMMENTO_POSTGRES=postgres://postgres:postgres@db:5432/commento?sslmode=disable
      # set this to flase after createring you account
      - COMMENTO_FORBID_NEW_OWNERS=false
      # optional sign in with x
      - COMMENTO_GOOGLE_KEY= # add value here
      - COMMENTO_GOOGLE_SECRET= # add value here
      - COMMENTO_GITHUB_KEY= # add value here
      - COMMENTO_GITHUB_SECRET= # add value here
    depends_on:
      - db
    networks:
      - db_network
  db:
    image: postgres:13.4 # newer then 13.4 did not work
    restart: always
    environment:
      POSTGRES_DB: commento
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
    networks:
      - db_network
    volumes:
      - ./commentodb/:/var/lib/postgresql/data
networks:
  db_network:

With Commento Running simply navigate to its sign in page, and sign up. From there you can configure any of the basic settings you need, it's pretty self explanatory.


Adding Commento++ to Ghost’s Casper Theme

To add Commento++ comments to your blog you need to make a couple of changes to your theme. To do this you need to first download your existing theme.

Settings -> Design -> Change Theme.

Next head over to Commento and copy the provided code snippet. Unzip your theme and open the file post.hbs in this file you will likely find an area appropriate for a comment widget to be added, past your code snippet there.

With your theme updated you can then upload it to the same place you downloaded it from. However if you are modifying the default theme you will need to rename the theme in the package.json file, you will also need to rename the final zip. Ghost will not let you replace the default theme, only change to a different one.

With that comments should now be working!

Complete Docke Compose File

version: '3'
services:
  ghost:
    image: ghost:4.44
    restart: always
    ports:
      - 2368:2368
    volumes:
      - ./ghost/:/var/lib/ghost/content
    environment:
      # see https://ghost.org/docs/config/#configuration-options
      database__client: sqlite3
      database__connection__filename: "content/data/ghost.db"
      database__useNullAsDefault: "true"
      database__debug: "false"
      url: "https://blog.<DOMAIN>"
  commento:
    image: caroga/commentoplusplus:v1.8.6
    restart: always
    ports:
      - 8080:8080
    environment:
      - COMMENTO_ORIGIN=https://<SUBDOMAIN>.<DOMAIN>
      - COMMENTO_PORT=8080
      - COMMENTO_POSTGRES=postgres://postgres:postgres@db:5432/commento?sslmode=disable
      # set this to flase after createring you account
      - COMMENTO_FORBID_NEW_OWNERS=false
      # optional sign in with x
      - COMMENTO_GOOGLE_KEY= # add value here
      - COMMENTO_GOOGLE_SECRET= # add value here
      - COMMENTO_GITHUB_KEY= # add value here
      - COMMENTO_GITHUB_SECRET= # add value here
    depends_on:
      - db
    networks:
      - db_network
  db:
    image: postgres:13.4 # newer then 13.4 did not work
    restart: always
    environment:
      POSTGRES_DB: commento
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
    networks:
      - db_network
    volumes:
      - ./commentodb/:/var/lib/postgresql/data
networks:
  db_network:

Final Thoughts

Overall I'm quite happy with Commento++, it was simple to get running and has a good number of features. Unfortunately at this stage it's missing the ability to moderate content from within the Commento web interface but it's not a major problem for a small blog. I am also not a huge fan of the default theme but I don't think i'll bother changing at this stage.