Grumpy Gamer

Ye Olde Grumpy Gamer Blog. Est. 2004

Dec 30, 2025

When I started using Hugu for static site generation I lost the ability to have comments and we all know now supportive the Internet can be, so why wouldn’t you have comments?

I wrote a few php scripts that I added on to Hugo and I had comments again. I decided to store the comments as flat files so I didn’t complicate things by needing the bloated MySQL. I wanted to keep it as simple and fast as possible.

When a comment is added, my PHP script created a directory (if needed) for the post and saves the comment out as a .json file with name as the current time to make sorting easy.

When the blog page was displayed, these files (already sorted thanks to the filename) were loaded and displayed.

And it all worked well until it didn’t. Flat files are simple. but they can be hard to search or maintain if they need cleaning up or dealt with after a spam attack. I figured I use commandline tools to do all of that, but it’s a lot more cumbersome than I first thought.

I missed have them in a sql database.

I didn’t want to install MySQL again, but my site doesn’t get a lot of commenting traffic so I could use Sqlite instead. The downside is Sqlite write-locks the database while a write is happening. In my case it’s a fraction of a second and wouldn’t be a issue.

The second problem I had was the version of Ubuntu my server was using is 5 years old and some of the packages I wanted wouldn’t available for it. I tried to update Ubuntu and for reasons I don’t fully understand I couldn’t.

So I spun up a new server. Since grumpygamer.com is a statics site I only had to install Apache and I was off and running. Fun times.

But the comment flat files still bugged me and I thought I’d use this as an opportunity to convert over to Sqlite. PHP/Apache comes with Sqilte already installed, so that’s easy.

A long weekend and I rewrote the code to save comments and everything is back and working.

Given that a webserver and PHP already needed to be installed, it isn’t a big deal to use Sqlite. If you’re not comfortable with SQL, it might be harder but I like SQL.


Comments:

Fabio 13h ago
Nice!, i'm using MySQL since 2002 on my blog, so it's impossible to change for flat files with more than 180k comments and 9.5k posts 😅 but i'll always recommend using a database, you can avoid a lot of problems with this kind of situations and it's easier to clean after spambots, there's a lot of abstractions easy to add to any code so you don't have to write everything again, but it's a choice!
Lone Pirate 12h ago
Noice! Keep it simple, but not simpler!

If one doesn't like SQL but still wants an embeddedable database, I'd recommend lmdb.
Renão 12h ago
Honestly, I liked that first iteration with the files anyhow :)
It matches the simplistic design of a (file based) static website - but as you said, there are downsides and pitfalls.

In the end it feels like making tradeoffs to have this feature - but it's worth it in my opinion.

Getting feedback right at your blog posts by having something like comments or favs/likes/toots/... can be motivating to keep on writing.
Rando from activitypub 12h ago
Really cool!
Elaine Marley 11h ago
Be nice! Plain text only.
Joe 9h ago
Ron?
Ron Gilbert ✔ 9h ago
What?
Sushinateur 5h ago
Cool :-) . Sending greetings from your database, it's nice over here ;-)
Sven 4h ago
Hi Ron!

I really like your games, blog and approach!

I can totally relate as to why a file based solution might be hard to maintain after those spam events, does the hcaptcha I see here help with that?

Cheers
Sven
Sepix 4h ago
I'm really just commenting because I can!
bil o sags 3h ago
I'm in an sql database. I love it
Ron Gilbert ✔ 3h ago
>> does the hcaptcha I see here help with that?

Yeah, it basically dropped the spam to zero. A bigger problem was script kiddies trying to do I don't know what. I'd wake up to 500 messages with random stuff in them.
Boybrush 3h ago
Hello again mr. Gilbert! Wishing you a super 2026 with a small hope for a remaster of Maniac Mansion, or... anything related with your adventure games :)
Sven 3h ago
But doesn't that mean they found a way around the captcha? Or is that 'client-side' only? Ah, you know what? Forget it. I sound like I want to extract information. :)

I hope you stay clear of those destructive SKs!
Ron Gilbert ✔ 3h ago
This was before I added captcha. It was easy to script adding comments.
Thomas 1h ago
Fir thise whi want something similar but don't want to write it themselves: check out Isso (simple, Python) and Remark42 (more features, Go).
00oofxoo00 32m ago
I liked the files approach and I use it everywhere just i usually don't have just one directory bit I calculate some hash and split them in a pair directory/name because the fs tends to work not so well when the number of files is huge. Anyway given the fact that SQLite comes with the server probably that is a good choice too.

Add comment: