Adding user-generated content to a static site using Staticman

I’ve been really interested in finding the ideal solution to add user-generated content, such as comments on a blog post, to a static site. My incursion started with a PHP middleman application that would interact with the now defunct Poole platform.

A few months later, a talk by Tom Preston-Werner made me rethink the whole concept, and I ended up building a bespoke commenting system. After several iterations, that project eventually evolved into a public, open-source platform called Staticman.

In a nutshell, I love the fact that my entire site lives in a GitHub repository and can go into a ZIP file with just a click, content included. I wanted to allow users to comment on my posts, but refused to accept the fact that introducing user-generated content would mean breaking that premise above.

Commenting platforms like Disqus are great, but the content is no longer under your control, not to mention the fact that it’s difficult to fully customise visually so it blends in with your existing design.

With Staticman, you can have user comments stored as data files in the repository, along with the rest of your content. When users submit a new entry, Staticman will process, validate and push it to your GitHub repository, either directly to the branch where your site lives or as a pull request for your approval.

Instead of writing an essay, I figured the video below would be a good way of showing the process of integrating the platform with a Jekyll site. It’s called Popcorn and it’s running on GitHub Pages.

The example shows how to use the hosted version available on staticman.net, but you can choose to run your own instance as the entire project is fully open source and available on GitHub.

If you need help or get stuck, feel free to drop any questions in the comments box below — which is powered by Staticman, of course! ∎

Comments

Ricard Torres

Thursday, August 11th, 2016, 08.45am

Fantastic work! Exactly what I wanted, to own my content. Never really liked Disqus and other comment systems because in the end the content is not in my site.

I’ll be implementing this on my site soon.

Thank you!

Ivan

Sunday, August 21st, 2016, 10.47am

Hi Eduardo. In the articles of your blog you are using the same method to post the comments. Is there an article where do you explain how to integrate staticman for every posts? I see that in this repository is generated a single folder per post (in _data/comments). Best regards!

Jim Withington

Monday, December 5th, 2016, 01.59am

Great stuff here! I’m gonna look to implement it soon – what a great idea.

Do you have any plans to keep folks from spamming it? I put a comment on Popcorn and saw that there were like 950 comments in the queue now.

Eduardo Bouças

Monday, December 5th, 2016, 11.07am

We offer some ways to mitigate spam, such as support for a honeypot field and integration with Akismet. These aren’t perfect and there is still some spam that goes through, which is an issue I definitely want to revisit.

As for Popcorn, it’s true that the repo is piling up with comments, but the vast majority is generated by actual humans and not spam bots, despite the random nature of the content. :)

Leave a comment