The thing one misses most when switching to static site generators is comments.

You can always use a 3rd party service like Disqus, but then it becomes a war against spam.

There are other creative options like creating a subreddit for your blog, and just moving the discussion there. It solves the presentation problem, and spam is pretty low if your site is not very popular.

Since the rise of Mastodon, various people have found ways to use Mastodon threads as their comment, and have them appear on the web site. The commenter can use any service in the Fediverse or Bluesky [1] to leave a comment - it is not restricted to Mastodon.

I finally figured out how to do it on my Pelican blog, thanks to posts like this.

I won’t go into the details - you can get them from that link. The big picture is:

  • Publish your blog post.
  • Make a Mastodon toot about it.
  • Add the Toot ID as metadata to your blog post, rebuild and republish your site.
  • Javascript on your post’s page will fetch the responses to your toot using the Mastodon API and present embed them onto the page.

The engagement occurs in the Fediverse (Mastodon, etc). Your post will have a link to the Mastodon thread for people to leave comments.

You can see an example of it here.

Any post that doesn’t have the Toot ID metadata will simply have comments disabled.

I made a few enhancements to his code:

  • If a comment has embedded images, I render them. (You can find them under the media_attachments attribute.)
  • If a comment has a content warning, I replace the content with a warning, and the reader has to click the link to read the content. (The sensitive attribute tells you if it has a content warning).
  • I removed avatars - they’re distracting.

Like most people, I didn’t bother threading - all comments are shown as a flat structure.

I should also add that with his/my code, your Mastodon toot needs to be public.

[1]Only if both you and the Bluesky user have opted in to Bridgy Fed. If you want to try that Bridge and are a Mastodon user, make sure you have a profile picture. The Bridge ignores you if you don’t.