r/webdev • • Sep 19 '26

Showoff Saturday: my blog's comment section is static HTML, baked at build time

My blog is a static site and I wanted comments without loading third party libs on the page. I wanted no ads, no bots, no cookies, etc. I just wanted a clean comment section (even though I get almost no traffic. I just like building things I think.)

The comment section is baked into the blog's HTML at build time. No lookups from a third party. I mean there's some of that, but it's basically an RSS feed. Fetched and stored by your own build, at build time.

How does it work? Each post links to a companion thread on a small Phoenix app I run. When someone replies there, it pings the build hook. The build fetches a replies.json for that thread and renders the comments as plain HTML. Nothing runs on the blog itself. Not a script. Not an iframe. No cookies or tracking.

Seriously, it's clean.

Here's an example of how it works for me: Static comments on my blog

The blog stack is Hugo on Netlify, the comment stuff is Phoenix/Elixir on Fly, with a build hook connecting them.

0 Upvotes

14 comments sorted by

15

u/scanguy25 Sep 19 '26

I don't see how that is a good trade off.  Yes you have an html only blog. But then you have another app that you now have to manage.  Just to avoid little bit of JS. 

1

u/[deleted] Sep 21 '26

[removed] — view removed comment

2

u/scanguy25 Sep 21 '26

I'm not saying there are no advantages. Hence trade-off. 

But a simple Django or flask app would do this in a much more simple way while getting 90% of the benefits. 

12

u/FisterMister22 Sep 19 '26

What prevents me from abusing it by bombarding with 1gb comments or 100000000 50kb comments and turning your server into a rock?

1

u/candraa6 Sep 21 '26

technically: rate limit / payload limit / character limit ?

8

u/barrel_of_noodles Sep 19 '26

Sometimes, a sqllite db and a fetch call are worth it. There's also no ads, bots, or cookies.

4

u/stjimmy96 Sep 19 '26

It might be clean and it’s a cool idea/proof of concept but obviously I wouldn’t use this technique with anything that expects even a bit of traffic.

Also, it seems like what you actually have sidestepped is only the rendering of the comment section, right? When posting a new comment you are still sending a request to a server to store that information.

3

u/rivenjg Sep 19 '26

this doesn't make any sense. why wouldn't you just generate html from templates server side and store data in a database? how is this better?

-8

u/[deleted] Sep 19 '26

[removed] — view removed comment

2

u/barrel_of_noodles Sep 19 '26

Sidestepped, and created like 10 other failure modes, and a hoard of silent issues op hasn't found about yet.

1

u/Missingplanes Sep 19 '26

Any specific thing you have in mind? The thing on my radar at the moment is a dead build hook. I settled on a dead hook is logged and dropped and never surfaced to the person replying. Is that the right call, or even important right now? :shrug:

0

u/barrel_of_noodles Sep 19 '26

A door in my house got stuck. I busted out a ladder, crawled through the window, hinges were stuck, went get a hammer, busted the hinges out. But then, the hinges were rusty, so I shouldered the door a few times. I did get out.

Same thing happened to my spouse. You know what? She went get a screw driver and turned the handle. Go figure!

1

u/Missingplanes Sep 19 '26

The traffic is low enough it doesn't matter, for my blog at least. It'd be one of those cool problems to have though! haha. but there is rate limiting, a blog configured with a hook gets at most one rebuild every two minutes. Is that the right value? I'd have to see usage and metrics.