Setting up Staticman for self-hosted comments
Yesterday, I finally got comments to work on this blog using
Staticman. Staticman is small Node.js
app that you can send
POST
request to from your comment form. Staticman will then upload the comment
as a file to the dedicated spot in your blog repository on GitHub (or GitLab).
If you turn on moderation, it will create a pull request instead. To do this, it
of course needs push rights to your repo, and setting up everything correctly,
including running your own instance of Staticman, turned out to be a bit more
difficult than it initially seemed.
First, you need to choose which endpoint of staticman you want to use. v1
(deprecated), v2
or v3
. For quite a while I was trying to use the newest
(v3
) endpoint of Staticman, with no success. Turns out, that v3
does not
support authentication through Personal Accesss Tokens anymore, but only through
GitHub applications (I found out here). When I made the switch
to v2
, things started to work out.
I am hosting my own instance of staticman on the free tier of Heroku. Two sources that really helped me doing so can be found here and here.
On the blog side, a staticman.yml
file is required, and a POST
request to
the right address in the comment form. Have a look at my Staticman
repo, and at thestaticman.yml
, _includes/comments-v2.html
and _layouts/post.html
files in my blog repo to see a working setup.
The next steps will be to make the comment form prettier, implement nested comments, get spam protection through Akismet and set up comment notifications using Mailgun.
If you have any questions or comments, feel free to leave a static comment, man!