7 min read

Adding (Anonymous) Comments to Your Ghost Blog Using Commento for Free

Add anonymous, beautifully designed comments to your Ghost blog for free using Commento
Adding (Anonymous) Comments to Your Ghost Blog Using Commento for Free

For years now, I've self-hosted Ghost on DigitalOcean to run this blog. I do not regret it; Ghost is an absolute pleasure to use.

However, it lacks some key features for a publishing platform, like built-in comments. Three major releases in, Ghost still doesn't ship with comments. Instead, in an attempt to remain lean, it expects us to use external solutions.

At first, I tried Disqus to host my comments–which was slow, ugly, and fickle. I then switched to utteranc.es, which certainly looked better, but now users had to login with Github first. This was still an improvement over Disqus, so I kept it for the moment.

I was planning to eventually move to Isso to get anonymous commenting, but then I came upon Commento– and it changed everything.

Why Commento is the Chosen One

I was swayed to choose Commento because:

  • It supports anonymous comments
  • It supports anonymous comments
  • It supports anonymous comments (I'll stop now but this really does make commenting painless)
  • It is the most beautiful/cleanest solution by far
  • The self-hosted version is free (but takes a bit more time to set up)
  • It's feather light, therefore also bloody fast
  • You can easily import all your Disqus comments as well as export from Commento if you decide to move
  • It's painless to configure spam detection thanks to the Akismet integration
  • You can even set up login with third-party sites (like Twitter) [that we're not doing in this post]

Without further ado, here's my day-long tinkering compressed into a concise guide.


This post will guide you through the following:

  1. Install PostGreSQL & create your pSQL user+database for Commento
  2. Create a subdomain, generate its SSL certificate, and point it to Commento
  3. Download Commento
  4. Create a service config file for Commento, and get systemd to keep it running
  5. Configure Commento and add its script code into your theme
  6. Add and configure Mailgun for sending verification/notification emails [Optional but highly recommended]
  7. Configure Akismet for filtering spam comments [Optional but recommended]

Remember, we're assuming that you're using nginx. Let's jump into it!

1) Install PostGreSQL and create DB

Commento uses PostGreSQL for storing comments. Install it using the following:

sudo apt update 
sudo apt install postgresql postgresql-contrib

At this point we're going to create a system user named commento, match it to a new database role (commento), then create a database named commento:

# Keep postgresql running
sudo systemctl enable postgresql

adduser commento

# Switch to newly created user
sudo -i -u commento

# Create role called commento. When prompted for superuser, say yes.
createuser --interactive

createdb commento

2) Download Commento

UPDATE ⚠🚨: It seems that the binary releases links are temporarily down. You can find the source files on Gitlab or Github and follow the compiling instructions here. There's also a really helpful comment by Nill in the comment section below.

Stay logged in as the commento user. Find the latest binary here. Right click the topmost Linux text and copy the link, then paste it below in the wget command to download the file:

# Replace the link you found on the releases page here

# Unpack tar file into newly created commento-server folder
mkdir commento-server
tar xvf BINARY_FILENAME_HERE -C commento-server

3) Create Subdomain and SSL Certs

⚠ Head to your DNS management panel and create a new subdomain, which we'll use to access the Commento dashboard etc. Point it to the same IP that Ghost uses. I'm using the commento subdomain.

This is a bit of a hack, but we're going to leverage acme.sh (that Ghost uses under the hood) to generate the SSL certs and config files.

# Switch to ghost-mgr user since we'll be executing Ghost commands. Exit to root first though (using exit command)
sudo -i -u ghost-mgr

# Navigate to ghost install root
cd /var/www/ghost

# Temporarily set Ghost site URL to Commento subdomain
ghost config url https://commento.YOURBLOG.com

# Get Ghost-CLI to generate an SSL setup for you:
ghost setup nginx ssl

# Switch back to your Blog URL
ghost config url https://YOURBLOG.com

The newly generated nginx config files need to get nginx to reverse proxy to Commento, so in /var/www/ghost/system/files/, update the commento*.conf files so their location block looks like this:

location / {
  proxy_set_header Host $http_host;
  proxy_pass http://localhost:8081;
//change port number to 8081, which Commento will be using

Save and exit.

4) Create a systemd service file for Commento

Create the service file using

sudo nano /etc/systemd/system/commento.service

Paste the following into it:

Description=Commento daemon service
After=network.target postgresql.service

Environment=COMMENTO_POSTGRES=postgres://commento:[email protected]:5432/commento?sslmode=disable

# Uncomment after setting up SMTP as specified below.
# Environment=COMMENTO_SMTP_HOST=smtp.mailgun.org
# Environment=COMMENTO_SMTP_PORT=587
# [email protected]

# Uncomment after creating your first user on commento.YOURBLOG.com

# Uncomment after creating Akismet acc and grabbing API Key. Paste it below.

Notice the ExecStart parameter set to the location where we extracted Commento to. The COMMENTO_ORIGIN parameter is set to the subdomain where we'll be accessing Commento. More info here.

We've commented out the SMTP parameters because when I tried it the first time with those enabled (even with Mailgun configured), I never got the verification email, and thus couldn't sign into the dashboard.

Save and exit. Now let's set the right permissions(read+write) for this file and get the service running

sudo chmod 644 /etc/systemd/system/commento.service
sudo systemctl start commento
sudo systemctl enable commento

5) Configure Commento

Head to commento.YOURBLOG.com and register a new user.

Create account page on Commento. Once done, we can go to our Ghost blog.
Create a new account on commento.yourblog.com

Immediately uncomment the COMMENTO_FORBID_NEW_OWNERS parameter in our service file above and re-run our service using

sudo systemctl enable --now commento

Once done, sign into Commento using those same credentials from above. Click on  Add Domain button in the top left.

Add Ghost blog domain in Commento comments hosting interface
Add in the domain where we're going to be embedding comments

Now, click on the domain you just added in the sidebar and you will be able to enable/disable anonymous commenting, import your old Disqus comments, and more. If you want to configure Akismet later, make sure Automatic spam filtering is enabled.

Configure comments options for Ghost+Commento
You can configure all your options here.

Once done, hit Save Changes. Now head to the Installation Guide tab and copy the HTML snipper, which should look like this:

<div id="commento"></div>
<script src="https://commento.YOURBLOG.com/js/commento.js"></script>

Now, download and unzip your Ghost theme, run yarn install in the theme folder followed by yarn dev. Open the post.hbs file and find the comment section code. Paste in the snippet, so it looks something like this:

Your comment section code in post.hbs should look somewhat like this.

Save and exit. Hit Ctrl+C to end the yarn dev, then run

yarn build

If you look inside the theme/dist folder, you should see the zipped theme. Upload this back to your blog on your Ghost admin panel and set as default.

Hooray! 🙌🏻🎆

You should now see Commento on your posts. Keep going to complete this setup.

I suggest you use Mailgun for sending those SMTP emails, so that you can be notified when new comments are added.

Sign up on Mailgun for a free account. You'll be asked to enter details for a credit card, but you won't be charged. Once done, head to Sendings > Domains.

Click on the Add New Domain

Click on Add New Domain. You will have to choose a subdomain from where Mailgun will be sending emails. Once done, you'll see various DNS records that you'll need to add. After you do that, click Verify DNS. If successful, you can head onto Sending > Domain Settings and click SMTP credentials.

You'll find every value you need here (including the SMTP email and password), which you have to replace back into our initial Commento service file. Uncomment all the SMTP lines.

Don't forget to run sudo systemctl enable --now commento  after you make your changes. That's it, you should be able to get notification emails now!

Optional: Add Akismet Protection to prevent spam comments

Go to Akismet and get yourself an account (It's free if your site is non-commercial).

As soon as you're done, you should see the API key. Copy it, we're going to need it.

Akismet Spam Detection for Comments on Ghost blog using commento
Copy the Akismet API Key listed

You can now re-edit /etc/systemd/system/commento.service and uncomment the COMMENTO_AKISMET_KEY parameter. Replace YOUR_API_KEY with your actual API key.

Once done, run sudo systemctl enable --now commento to update your changes.

Aaand that's it! If you reached here, you should have gotten Commento up and running. If you want to test it out, just scroll down. Hope I helped!

Bibiliography: This article was largely made possible through two awesome guides, https://blog.kye.dev/self-hosting-commento/ and  https://techroads.org/building-a-self-hosted-commento-system-for-embedding-comments-with-docker-and-traefik/. I found errors (such as the contents of the service file) and outdated info in 1) whereas 2) was slightly unclear for beginners and made use of Docker, so I thought I'd write down a guide that provided greater understanding and less head-scratching.