Commit 2f49e914 authored by Jamie Tanna's avatar Jamie Tanna

Announce automagic webmentions on deploy

parent bbe0d041
Pipeline #81262020 passed with stages
in 8 minutes and 3 seconds
title: "Sending Webmentions Automagically on Deploys of the static website"
description: "The journey to getting Webmentions sending automatically from my static website,"
- webmention
- indieweb
license_code: Apache-2.0
license_prose: CC-BY-NC-SA-4.0
date: 2019-09-10T09:30:30+0100
slug: "webmentions-on-deploy"
image: /img/vendor/webmention-logo.png
- text: IndieNews
- text: /en/indieweb
# Background context on
For those of you who have only read this post on my website, you may be unaware of how this site is set up, which will provide a bit of background for why this is something to celebrate.
My website is a static website built with the [Hugo]( static site generator, and deployed to Netlify. Because my site is static, it means I can't easily send [Webmentions](, without following a similar process to <span class="h-card"><a href="" class="u-url">Max Böck</a></span>'s article [Static Indieweb pt2: Using Webmentions](
This would work perfectly, aside from the fact that before it gets deploy to Netlify, I have a full build/test/deploy pipeline in [GitLab CI]( to give me confidence that the site isn't going to break something for my users.
This pipeline runs for anywhere between 6 and 10 minutes in total (depending on wait times + latency), which is quite a slow process and reduces the feedback time to be able to share content. I used to have a stage in the pipeline which, after deployment, would then notify search engines of updated content, and send me a push notification to say the site is deployed. This gave me a nudge so I could then know to go through and share it wherever it needed to be, but manual work is never my favourite!
Some time ago I created a webhook received from GitLab to a Java Spring Boot API which would allow me to extract that from my pipeline, and execute it outside of that, on a successful pipeline run from GitLab.
This stage was the perfect place to be wanting to send Webmentions, as it was triggered after a successful site deployment, so I knew my content would be discoverable at this point.
# Getting Webmentions Sending
I decided that I would send a Webmention for each item in my social feed ([h-feed](, as that was the most discoverable feed of links that a user would be going through.
My main concern with this was the requirement for me to implement a Microformats2 parser in Java, because there doesn't seem to be a popular one I can use. Fortunately, I had a bit of a brainwave, and have delegated out to []( to perform the Microformats2 parsing of the feed.
With this, I then had a list of posts (be they Indie posts like a bookmark, or a full blown article), but then had the challenge of finding all the links on the page, and sending the Webmentions.
Again, I wasn't enthused about having to write this all myself, but fortunately found <span class="h-card"><a href="" class="u-url">Kevin Marks</a></span> had built []( which had a handy `/mentionall` endpoint. I was able to send it a URL, and Kevin's service would do the hard work for me - extracting any URLs in the page, then performing Webmention discovery on the URL, and if it has a Webmention endpoint, send one.
I was really happy with this process, as it managed to save me some time in implementing all those pieces, and helped me unlock the thing I actually wanted to build - automated webmention delivery!
At some point I'll embrace [the plurality principle]( and implement this all myself, but until then, thanks folks for making it easier for me to get up and running!
And even better is the fact that this took me all of about 5 hours' work to get going (largely slowed down by the fact that I couldn't get asynchronous processing working because I was editing the wrong Spring configuration file in my project!)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment