Free, One-Command, Self-Hosted Commento Deployment for a Hugo Site

tl;dr I wrote an ansible-playbook that let’s you deploy Commento, the open-source, privacy-focused comment section solution to your static site. Check out the GitHub repo and read the README to get started.

Sections

Introduction

Commento is an open-source, privacy-focused alternative to Disqus for adding comments to your static site.

If you want to add this to your Hugo site, there are tutorials out there about how to set up a self-hosted version of Commento (I like this tutorial which uses docker to make the setup easy). But none of them are turnkey, one-command solutions.

So I wrote my own turnkey, one-command solution. You can check it out here: commento-ansible-playbook and follow the README to run it.

Why use this?

You could get a “free” account with Disqus and just paste their javascript into your site and call it a day. But then your users have to deal with annoying, targetted ads. Plus you don’t really own the service. They can shut it down or decide to start charging you any day, and you’ll be stuck.

With a self-hosted service, you own it. No one can take it away from you. And Commento is open-source and self-hostable. It’s also centered around privacy rather than centered around advertising.

And now it’s easy to set up a self-hosted solution, too. As long as you have a Linux host running Ubuntu 20.04 or Debian 10+, you can make this work. You can even make this work on an old laptop home server because this playbook supports HTTPS over non-standard ports.

Plus you save a lot of hassle. You don’t need to register a domain name and fiddle with DNS to point it to a new machine. You don’t need to get an SSL cert and keep it up to date. You don’t need to write any systemd files and link them here and there on a remote host. You do get to use that saved time for other things, like making more content for your users to comment on!

Okay, how do I use it?

Follow the README for detailed instructions. The simple summary is that you just need to do the following:

  1. Get a free subdomain at DuckDNS.org, a free, Dynamic DNS service. (Yes you have to use a subdomain from here. It’s free and easy but most importantly it allows you to get an SSL cert without having port 443 open, and that was a requirement for me)
  2. Get a machine with Ubuntu 20.04/Debian 10 on it that you can ssh into. It can be a $1.25/mo. VPS (see here) and everything will work just fine.
  3. Install ansible and clone this git repo: commento-ansible-playbook.
  4. Input your DuckDNS subdomain, credentials for Gmail (to send password reset and other moderation emails), Akismet credentials (optional, for automated spam detection), and Linux machine ssh credentials.
  5. Run the one-command deployment ansible-playbook full_setup.yaml --ask-become-pass
  6. Enjoy your new comment section.

Demo

It’s that simple. Don’t believe me? Check out a demo of me deploying Commento with one command to a Digital Ocean box, right after spinning it up.

demo of commento setup on a remote box

I want to run this on a home server, anything I should know?

I made some special decisions in this playbook to support people who want to run Commento from a machine at home. Namely both the use of a Dynamic DNS provider for domain names and the decision to procure SSL certs in a way that does not require ports 80/443 to be open helped make this a possibility.

If you want to do this, a couple things to know:

  1. If you have a dynamic IP at home (most people do), then make sure to install the DuckDNS dynamic IP client on your machine beforehand. Follow the installation instructions for the option that matches your setup (I find ‘linux cron’ and ‘linux GUI’ to be the easiest).
  2. You’ll need to forward some ports for your installation to work correctly. Default is port 443, but if your ISP blocks that port, you can set a different port (see the README for more details). I found openmyip.com to be the best online guide to port forwarding since it has detailed instructions for each router on the market and troubleshooting tips for each one as well.

Acknowledgements

A free, self-hosted comment section service you can drop into a static site in less than 15 minutes is pretty snazzy. But none of it would have been possible without these free and/or open-source solutions. If you do have a little bit to spare, consider donating to these projects:

Farhan Kathawala
Farhan Kathawala
Full Stack Web / React Native Developer

A happy full stack developer sharing tidbits of everything and anything web / mobile app dev.

Related