I had previously displayed WebMentions on posts via a script that ran on each pageview, queried webmention.io for mentions relevant to that page and rendered them - entirely based on the original approach documented by Sebastian de Dyne.
In the most recent iteration of changes I have:
- adapted the processing of inbound webmentions so they are pulled periodically into data files in the repo by Github actions, then processed when the site is built so they are baked into the rendered static pages
- added a Netlify build plugin to push outgoing webmentions from my site to the sites I link to
Processing inbound web mentions
- a Github action that runs every thirty minutes and calls a retrieval script
- the retrieval script which pulls webmentions from webmention.io and stores them as data files in the source repo for the site
- a processing script that is run each time the site is built - this reads the raw webmentions and processes them into a form suitable for Hugo to digest
- changes to page layouts to render a webmentions section
For all of this I am indebted to Rowan Manning’s approach.
Sending web mentions when the site is built
This is the other side of the coin. There are a range of approaches, but I decided to go with a Netlify build plugin configured to only run on production builds.
All the examples I could find work by processing the RSS feed for the site, and most take the approach of posting webmentions for any remote sites linked from the last (or a configurable last number of) posts. This will fall down if you ever create more than one post in between publishes - rare but not impossible.
A note to myself - new functionality based on code developed by others, I need to spend some time to make the repo for this site openable, then make it public.