A blog by Stuart Langridge

as days pass by

scratched tallies on the prison wall

Enabling Webmentions

Well, everyone's doing Webmentions these days. So, there's a bandwagon here to jump on.

All this is really my fault. It is a good idea that, when I write a post which links elsewhere, that the elsewhere gets told that I linked to it. This way, the web stays connected -- obviously, a link from A to B is one-directional, and these notifications allow links to be two-directional.

So, 12 years ago, I invented Pingback. Sorry.

Pingback uses XMLRPC because that was the cool thing at the time and because I was young and foolish and had a peanut for a brain. Ian Hickson took my vague spec and kicked it in the arse to make it a proper spec, and it got adopted really quickly. Back then, when the world was young, everything got adopted really quickly; there was so much new ground to be broken that coming up with a reasonable way to do something (permalinks, RSS autodiscovery, pingbacks) meant that it got picked up by everybody.

However, XMLRPC is considerably less popular than it was, and is really heavyweight for this sort of thing. We've learned since then that HTTP can actually do all this stuff for us way more simply1 and we've learned how best to use HTTP to express the whole bunch of loosely-defined agreements and protocols that we now call the Open Web. Hooray! And I should get on board, partially as penance and partially because it's just a jolly good idea.

Jeremy implemented this for his stuff ages ago (and I defer to his post for a more detailed explanation of what webmentions are), but the thing which prompted me to actually get off my arse and make this happen was Aaron writing up how he did it2 with Jekyll, a static site generator. Now, adpb is also a static site (with Pelican, a Python site generator), and I really liked Aaron's idea of baking one's incoming webmentions into the page at build time and then re-fetching them live with JavaScript at run-time to display any webmentions which have come in since the last time I regenerated the site. Also like Aaron, I didn't want to run my own webmentions endpoint (because databases are hassle), and so looked at Pelle Wessman's webmention endpoint which he's spun up on Heroku. One quick signup and I was good; I could send webmentions and Pelle's app tracked them for me. Nice.

I then, of course, needed to fetch the webmentions for my whole site at build time -- the initial version of the endpoint didn't do this and instead required requesting the webmentions for each individual URL, but I have about eighteen hundred posts on this site and so a quick patch submission later and I could grab all the webmentions for kryogenix.org in one request. Pelle graciously fixed, merged, and deployed said patch, and now we were off to the races.

I put together something approximating a Pelican plugin for webmentions3 and wrote some JavaScript to do the live fetching, and also pinched Jeremy's idea of being able to manually submit an incoming link. And there we have it. I'm part of the Indie Web.

It would be nice if this stuff were in core WordPress, I'd say. Also, people have started thinking about webmention spam and how to avoid it; Vouch seems a reasonable approach, and it'd be interesting to see where that discussion goes and whether we can fix this before it becomes a problem. Also, I have added myself to the indieweb IRC people list and am hanging out on freenode IRC in #indiewebcamp.

  1. ok, ok, Roy Fielding, you knew already
  2. because Aaron and I were having a blog-to-blog conversation, and that sort of thing is the perfect environment for webmentions to thrive and prove their worth
  3. code is in a gist on github rather than a nicely submitted plugin project, because it's got too much stuff in it which is hardcoded rather than generic, but it would be a useful start for someone wanting to build something proper
I'm currently available for hire, to help you plan, architect, and build new systems, and for technical writing and articles. You can take a look at some projects I've worked on and some of my writing. If you'd like to talk about your upcoming project, do get in touch.

More in the discussion (powered by webmentions)