Most blogs nowadays have some kind of comment section where people can leave their feedback, but most popular tools including Disqus don’t exactly fit the requirements of our modern time. On the search for a self-hosted, privacy-focused and free alternative to the mainstream tools, I hit my head on Commento.
Commento is a free, open-source, privacy-focused Disqus alternative that can be self-hosted on your hardware. In this article, I’m going to show you how to set up your comment section using Commento and the different configuration options that are available as well as the current development status of the Commento project.
If you are still unsure about Commento or if you even need a comment section, I recommend that you try it out in my comment section below and go from there.
Table of contents
Open Table of contents
Before you begin this guide, you’ll need the following:
- A server with a public IP-Address on which you can host Commento.
- (Optional) A domain name and DNS A-Record pointing your domain to the server mentioned above.
Before we get started
Before we get started I wanted to mention that the original Commento Gitlab repository is no longer maintained. Therefore, we will be using an updated version from Github, which is much more active and has a lot of useful new features.
Here is a list of some new features that were implemented in the Github repository:
- Guest commenting (Without needing to login)
- Direct SSL support
- Various bug fixes and improvements
Setting up Commento
Commento is a Golang based application that uses PostgresSQL as the backend database and can easily be deployed using either the available binary or Docker. This guide will use Docker-Compose since it allows us to easily orchestrate both Commento and PostgresSQL with a single configuration.
Remember to change the
COMMENTO_ORIGIN to the domain you want to use or to localhost if you are testing it locally. You can now start the configuration using the
docker-compose up command.
docker-compose up -d
After starting, you should now be able to access Commento on localhost:8080 and see the following UI.
If you want to include Commento into an HTTPS site, you must add a valid SSL certificate and expose the service on a domain or subdomain. This can easily be achieved using the
nginx-proxy container with the
Both of them can be started using the following docker-compose file. Note: Make sure that the
nginx-proxy is in the same Docker network as Commento so they can communicate.
Once these containers are running, we need to tell the
nginx-proxy which port of a container it should expose and the domain it should expose the port to using the
LETSENCRYPT_HOST environment variables.
After restarting the containers Commento should be accessible on the domain you specified.
Creating a user
Now that the Commento setup is finished it is time to create an admin user account, which will be used to access and manage Commento. To start, click on the
SignUp tab on the top left, fill out the required fields and click
Forbid the creation of new owners
Since you don’t want other users to create an admin account on your server, you must disable the creation of admin accounts using the
COMMENTO_FORBID_NEW_OWNERS environment variable.
Once you restarted the container the creation of new admin users should be forbidden. You can test this by visiting the Signup page and trying to create a new user.
Adding Commento to your website
Now that everything is running and you have access to the admin dashboard, you can add Commento to your website. To do so, you just need to copy the following code into your HTML (Note: Please make sure you change the URL to your corresponding domain).
Once you visit your page you should see something similar to this:
You can now start trying out your comment section and checking if everything works correctly. There are also some more configuration options like email verification and social logins, which we will look at in the following sections.
If you would like to receive email notifications whenever someone comments on one of your articles you will need to add SMTP to your Commento configuration. There are a lot of free SMTP services out there, which can be used here (I use Sendgrid which has worked great so far).
After restarting Commento you should now receive email notifications for comments and use extra functionality like exporting all your comments.
Enabling Social logins
Social logins can also be enabled using environment variables and require the API Key and secret of the social service you want to use. Here is a list of the available environment variables:
In this article, you set up your own privacy- and performance-optimized comment section and added it to your blog.
If you have found this helpful, please consider recommending and sharing it with other fellow developers and subscribing to my newsletter. If you have any questions or feedback, let me know using my contact form or contact me on Twitter.