Really Static Comments with Staticman

Static sites have many advantages, we always say. But they also have at least one large inherent disadvantage: they are not dynamic. Not being dynamic means that forms that alter the content of the site itself are not possible without going outside the static side of things.

That's why for comments we all end up using something like Disqus or some other alternative service, or Isso if you prefer the annoyance of self-hosting instead of the annoyance of having your data be owned by someone else.

So... how about a service that lets you do forms, but:

  • You keep full control of your data

  • The service doesn't limit what you can do with the data

  • You can use it for most things a form is used for?

  • It's free!

That service is called Staticman and it's awesome.

This is how it works:

And Staticman will take the form's data, convert it to JSON, YAML, or whatever, and put it back in your site's GitHub repo. You can choose whether it uses "moderation", and do that via a pull request, or not, in which case it just commits directly.

Nikola can then use those data files from its templates, like in this example which displays a form to post comments, and a list of previous comments.

Then, if you combine that with an autobuild system, like using Travis or Netlify or Gitlab that means a few seconds/minutes after the form is submitted, the data appears back in the site.

So, what do we end up with? A site with comments, where you own all the data, and not even need to use Javascript to display the comments!

You can see it in action in this demo site: staticman-demo.netlify.com

TODO: submit the form via Javascript instead, so it does it in the background instead of dumping JSON results on you.

Have fun, leave a comment :-)

Comments

Comments powered by Disqus