Reply via Webmention

Blogs are experiencing a revival, many people are turning away from centralized and closed platforms. Many new blogs are emerging and old blogs are waking up again. That's nice, but we still have some trouble connecting with each other.

The Komments and IndieConnector plugins want to make it a little easier for you. If you receive a webmention, you can now reply directly to it from the panel.

Mini-Excerpt: Webmentions

To understand how this works, we need to look at how Webmentions work. Let's take two blogs that both support Webmentions:

  • Blog A publishes a post
  • Blog B reacts to Blog A's post in its own post
  • When Blog B publishes the post, Blog B sends the post URL to Blog A
  • Blog A receives the URL, fetches it, and reads the data
  • Blog A can now display Blog B's post as a comment

Of course, a lot more happens in the background, but for this post we're focusing on the basics.

Sending replies

Let's say we are Blog A and just received he Webmention from Blog B via the IndieConnector, which we display under our post with the komments plugin.

If we were to reply to this comment now, Blog B wouldn't know anything about it. The operator of Blog B would have to specifically visit our post to see if we had responded.

But that can change with the new feature in both plugins!

If we answer a Webmention in the panel, our answer will not only be saved as a comment on our site, but also a Webmention will be sent back to Blog B.

If Blog B receives our Webmention, it will try to read our site and this is where we run into the first problem, because on the one hand our site contains various comments and on the other hand the microformats on our site would ensure that our article is read as a Webmention, not the comment.

With a small trick, we can change that, however.

Comments

Did you know that every comment on your site has its own Permalink? A deep link, like you might know from your normal pages. Kirby's Permalinks look like this: https://example.com/@/page/some-unique-id.

And each comment also gets an identification number, a UUID. The Komments plugin also provides a route that allows you to access each comment via its UUID. If you look at the details of a comment in the panel, you'll see this Permalink:

Clicking this Permalink will open the page to which the comment belongs and scroll to the comment.

However, this behavior can now be changed.

In the config.php we can now activate the following option:

'mauricerenck.komments.webmentions.sendReplies' => true

This ensures that a Webmention is sent as soon as we reply to a Webmention in the panel. On the other hand, it also changes the behavior of the permalinks.

Instead of scrolling to the comment when opening the permalink, a single page is displayed that only shows the comment including microformats.

This means that the sent Webmention no longer refers to the post but exclusively to your comment. This can be read and displayed in our example by Blog B.

Sending Webmentions

Normally the IndieConnector plugin only sends Webmentions when it discovers links on a page during publishing or saving. In our specific case, however, we neither save nor publish pages. For both plugins to work together, we also need to tell IndieConnector to react to comment Webmentions:

'mauricerenck.indieConnector.send.hook.enabled' => true

This option activates a new hook that can now be triggered by other plugins and subsequently sends a webmention. The Komments plugin calls this hook and IndieConnector sends the Webmention.

As a result, our comment appears both on our blog and Blog B, and the operator of Blog B receives it automatically, without having to constantly check with us. 🥳

Conclusion

With just two changes in your config, you can now connect your blog even better with others. If more websites implement this or a similar feature, they will gradually become a decentralized network – without complex server management or configurations.

The template for individual comments is pretty simple, but you can overwrite it like all templates in Kirby by creating a new PHP file: site/templates/komment-response.php.

Copy the content from site/plugins/komments/templates/response.php and customize it as you like. Be sure to keep the microformats so that other sites can read the content correctly.

This is the first step, I plan further refinements, like liking a webmention for example.

The feature is available to you from version 2.7.1 of the IndieConnector and 3.1.0 of the Komments plugin. Have fun!