Author Ernestas Narmontas
Static Comments for Jekyll with GitHub Pages
Disqus is the most popular comment solution for Jekyll at the moment, but it has one huge problem. It sucks. It’s free proprietary software filled with tracking scripts that slow down your website.
Since Jekyll sites are static there was no way to store comments without such external service or database. Well, at least until Staticman.
Staticman is an open source static comment solution for your Jekyll site. It allows you to have user-generated content on a static website.
I just have finished setting it up on this blog. I have used this amazing guide by Travis Downs. I’m really happy how it works. Here’s a quick summary:
- Staticman can be hosted on any platform with NodeJS. I am using free Heroku app, but there are many other options. More details here.
- Jekyll theme will need a simple HTML form that will post comments to Staticman API. I have borrowed most of HTML/CSS/JS from the guide I mentioned earlier.
- Staticman will create a pull request with the comment data. It can also commit directly without approval. Note: GitHub access token is required.
- You’ll approve the comment and merge the pull request.
- GitHub Pages (or your custom solution) will build your Jekyll site with the new commit.
- Comment will appear on your website.
That’s it. When you get it up and running, it works. Try it below.
Xin chào, test
It works, right?
Yep, even replies are working with some HTML/JS magic.
It does, but how does it track a user?
Each comment has a permalink with unique ID. When you reply to the comment, the ID is saved to the
replying_to_uidfield, which is then rendered as a reply. You can see an example here.
However, it doesn’t support nested replies, that’s why I can’t reply directly to you now, but I can always use the same thread.