Hugo with comments
So, I made this blog to write again, and chose to use Hugo. And while Hugo is amazing, it’s a static site. And while I can add comments to my site using services like Disqus, I sort of wanted to roll my own comment service. So here it is! Below this post, you can comment.
I wrote a simple API server that has only two actions:
- Get a list of comments
- Post a comment
The server is written in Go (obviously). It stores its data in Redis. To (hopefully) reduce the amount of spam, I can manually approve all comments, and I run new comments through Akismet to auto-approve them if Akismet doesn’t think they’re spam.
The code for this comment server is on github at Luit/comments, and if you want to try it, you can install it by doing:
go get luit.eu/comments
Running it is as simple as … well … just running it. Make sure you have a
Redis server running at the default Redis port (with no password). If you want
the Akismet support to work you’ll have to pass an
variable. By default it’ll run listening on
Using it from a blogpost requires two additions to your template:
<script>that’ll request the list of comments
<form>that posts to the comment server
This page has both, so look at the source here to see an example. (warning: I am a horrible client-side programmer)