← Back to context

Comment by susam

10 hours ago

If you are rendering your blog or website with a static site generator, you could also consider importing comments as content files into your website source and then rendering them as part of the build. The full workflow would look like this:

1. Accept comments via email, CGI scripts, server-side program or by any other means that suits you. A simple hack that requires no server-side scripting: if you run your own web server, you can submit comments as GET query parameters logged in access.log, then extract them using grep, sed, etc. Personally, I use a server-side program to accept POST requests and write comments to a text file on the web server.

2. Review submitted comments. Delete spam.

3. Add comments to your website source repository as .md, .html or whatever format you use, similar to how you add blog posts as content files to your source.

4. Render comments alongside the rest of your site using your static site generator. Depending on the nature of your static site generator, this may require using or creating a template or layout that iterates over the comments and renders them.

It is a fairly hands-on workflow, so it may not suit everybody, but this is how I do it for my personal website. I see two main benefits of this approach. Since the review is manual in step 2, no spam can ever make it to my website. Step 3 ensures comments live entirely under my control, so I never need to worry about migrating them between platforms in the future.

I can see how that would work. For a small website, you're probably only looking at a few comments per day at absolute most, and you'll be reviewing them anyway to filter/approve them. (And the implementation lends to easy automation, since you just need to programatically update the Markdown file instead.)

Sounds terrible