Add Webmention support to your website in ten minutes

Webmention is a protocol for sending and receiving notifications about webpage link relations. It’s fundamentally about tearing down the walled gardens created by the leading social networks, and allow for interactions using links across websites and platforms on the open web.

Using Webmention, Webpage A can notify Webpage B that it has added or removed a link to it. This can be useful for a website that wants to track comments, reactions, citations, and other uses for linking even when those interactions happen on another website.

Websites can use Webmention however they like. They can chose to curate and display their Webmentions publicly on the relevant page, or just as a way to collect reactions to webpages they’ve published. It’s similar to earlier linkback standards like Trackback and Pingback. However, the Webmention standard encourages link verification, addresses DoS vulnerabilities, and reduces the abuse potential compared to those earlier protocols. It also encourages notifying pages when links are removed and not only when they’re added.

Implementing Webmention

The Webmention specification doesn’t take more than an afternoon or two to implement; helped by the excellent free validation and testing utility called Webmention.rocks.

This article’s headline promised “ten minutes” and not a couple of afternoons, though. I’ll deliver on the headline, but I’d like to encourage people to implement it themselves. This isn’t always an option though, such as when you’ve a static website or publish on a website or platform out of your control.

Webmention can be used for non-public communication, but it’s intended to be used on publicly accessible websites. Unless you expect to receive notifications from private platforms, you can outsource the endpoint that will be receiving Webmentions to a free-of-charge hosted third-party service. The rest of this article will go into how you can do that in a few easy steps.

Receiving Webmentions

To receive Webmentions, you need an HTTP endpoint capable of receiving and verifying them, and you need to add Webmention auto-discovery information to your webpages.

You can sign up and use Webmention.io to receive your website’s Webmentions. You need to login with your domain name to register it to get set up to receive Webmentions.

Once that’s done you’ll get an HTTPS endpoint address that you’ll need to add to your webpages so Webmention senders can auto-discover it. Webmention uses two auto-discovery methods; you must support the first method and should support the second one as well.

The required Webmention endpoint auto-discovery method uses a link element with the webmention link relation. You must include the following (with your endpoint in the href attribute) on all pages you want to receive Webmentions for:

<link rel="webmention"
  href="https://webmention.io/example.com/webmention">

The second optional-but-encouraged endpoint discovery method uses a Link HTTP response header. Senders should prefer this method as its less resource-intensive and can be discovered using a simple HTTP HEAD request. You should add the following response header (with your endpoint) to all webpages and resources you want to receive Webmentions for:

Link: <https://webmention.io/example.com/webmention>; rel="webmention"

Once you’re set up to receive Webmentions, you can retrieve your Webmentions using Webmention.io’s Application Programming Interface (API) or your domain’s custom Atom syndication feed. It’s impossible to miss the instructions on how to retrieve your notifications after you’ve signed up with Webmention.io.

You can simply update the endpoint addresses if you later decide to use another hosted service or do your implementation. Webmention.io isn’t only free-of-charge but a free software project that you can self-host. I don’t believe this shouldn’t take you more than a couple of minutes.

There are also Webmention plugins available for all major content management systems (CMS) if you prefer building on top of your CMS. When you’re set up to receive Webmentions, you next need to decide on a strategy for sending them.

Sending Webmentions

You’ve got a lot of options when it comes to sending Webmentions, but Webmention.app is a good place to start.

Update (): The Webmention.app service has been discontinued. There is currently no other good free alternatives.

Webmention.app is available as a free-of-charge hosted API that you can feed your webpages or even a syndication feed file and they’ll take care of scanning your pages and sending outgoing Webmention notifications. The API is rate-limited to process a couple of pages per day, which should be more than enough for most small blogs and websites.

Alternatively, you can download their open-source command-line client and do the webpage parsing and send the notifications from your computer.

Depending on your work flow, you may want to run the command-line program as part of your website deployment/publishing process, or automate periodic calls to their API.

What about webspam?

Webmention is as susceptible to spam submissions as any other publicly facing web service. It hasn’t been a huge problem for me, but you may need to maintain a blocklist or implement some other anti-abuse measurements if it becomes a problem for you.

Unlike earlier page-to-page linkback notification specifications like Trackback or Pingback, the Webmention specification recommends that receivers should verify that the sending page links to the destination page. It also suggests doing these checks asynchronously, to reduce the impact of Denial-of-Service (DOS) attacks. This check can be repeated periodically.

You can conceivably add more checks like looking up the sending page’s URL through any number of free-of-charge anti-phishing, anti-malware, and domain reputation checks as well.

Mentioning Webmention

You should test your website with Webmention.rocks after you’ve made it capable of sending and receiving Webmentions. The last thing you need to do is to mention Webmention on your website, and tell your web-peers about it to increase interest for and adoption of the protocol.

It probably won’t come as a huge surprise to anyone who’ve read this article that Ctrl blog now can send and receive Webmentions!