Free, One-Command, Self-Hosted Commento Deployment for a Hugo Site
- Why use this?
- Okay, how do I use it?
- I want to run this on a home server, anything I should know?
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.
Why use this?
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:
- 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)
- 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.
- Install ansible and clone this git repo: commento-ansible-playbook.
- 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.
- Run the one-command deployment
ansible-playbook full_setup.yaml --ask-become-pass
- Enjoy your new comment section.
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.
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:
- 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).
- 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.
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: