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

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!

Josh

Friday, August 19th, 2016

Is it possible to add multiple data sets to the staticman object on _config.yml? Separate fields for different collection types?

Eduardo Bouças

Friday, August 19th, 2016

Josh, not at the moment, but that sounds like a really useful request. Do you mind creating an issue with that on the repository (https://github.com/eduardoboucas/staticman)? Thanks!

Ivan

Sunday, August 21st, 2016

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](https://github.com/eduardoboucas/eduardoboucas.github.io) is generated a single folder per post (in _data/comments). Best regards!

Robson

Friday, August 26th, 2016

**Wow**! This is an amazing tool! Muito obrigado! Now, I can think about to how to ditch Disqus! Thank you!

Robson

Friday, August 26th, 2016

O link para o github está errado: https://gitub.com/eduardoboucas/staticman Percebeu? "gitub". Nem precisa aceitar esse comentário.;-)

Viet-Anh Nguyen

Saturday, October 8th, 2016

Thank you very much!!. I want to say it immediately because after some hours looking on the Internet I've found a wonderful comment system! :D <3

Jim Withington

Monday, December 5th, 2016

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

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. :)

Shawn

Monday, December 19th, 2016

Hi there! I'm also writing this comment just to try Staticman before trying it on my site. Feel free to delete it!

Leave a comment