Comments, Ahoy!

After a bit of tinkering, I've managed to get all the site's comments moved from WordPress to Hugo.

When I first started to allow comments on my site, they poured in. But as time went by, people started to lose interest, and the flood dried up. Now the comment section on most posts looks like a wasteland. But some of my How To posts attract quite a few comments from people who ask questions, and amend the topic the post covers. On those posts, comments can be very useful, so they had to be migrated from WordPress to Hugo - doing it was just never high priority.

How?

Displaying dynamic comments on a static site can be solved in many ways. Disqus is popular, but they’ve had some privacy issues in the past. There are also a lot of different self-hosted options available, but I really didn’t want to go through the hassle of setting up a dedicated service with a lot of moving parts when the number of comments is as low as it is.

So I went for the most basic solution I could think of: With a PHP script, I pulled the comments from the WordPress database, and dumped them as JSON files. Then I moved the JSON files into the Hugo leaf node of each post. With a couple of new template partials, comments are now added to the posts when Hugo builds the static site. There are 897 posts with comments, but interestingly enough, the site’s build time didn’t really increase.

But how do you comment? You send an e-mail, and I manually add the comment to the correct JSON file!

What’s Next?

I have to admit sending an e-mail isn’t the sexiest way to submit a comment. People are used to web forms, after all. But right now, it’s good enough. In the future, I might add a simple web form that sends the comment to me as an e-mail. I can show a message saying that the comment is “being approved” to give the submitter the impression that something is actually happening behind the scenes.

I’m also considering added WebMention, but from the little I’ve read about it, I get the impression that the work of getting it up and running outweighs the benefits. If the number of submitted comments somehow miraculously increases beyond a number where handling everything manually becomes a drag, I’ll reconsider.

So, what do you say, people - is sending an e-mail good enough for you!?


Feedback

This post has no feedback yet.

Do you have any thoughts you want to share? A question, maybe? Or is something in this post just plainly wrong? Then please send an e-mail to vegard at vegard dot net with your input. You can also use any of the other points of contact listed on the About page.


Caution

It looks like you're using Google's Chrome browser, which records everything you do on the internet. Personally identifiable and sensitive information about you is then sold to the highest bidder, making you a part of surveillance capitalism.

The Contra Chrome comic explains why this is bad, and why you should use another browser.