Adding Webmentions to Jekyll

I've added some basic support for webmentions to my Jekyll-powered site using webmention.io and this Jekyll plugin. If any of my posts are mentioned elsewhere and my site receives a webmention, it's displayed below the post content.

Since Jekyll is a static site generator, the plugin can only check for new webmentions when the site is rebuilt. Netlify uses continuous deployment to keep my site up to date, so any time I commit a change and push it to Github, the site is automatically rebuilt and deployed. To supplement this, I also use IFTTT Webhooks to trigger a build every 24 hours, allowing my website to check for new webmentions on a daily basis.

Although the plugin is easy to install and use, I ran into a hiccup when trying to work on my site locally. I'd normally use the following command to serve the site as I work on it, allowing me to see changes reflected:

bundle exec jekyll serve --limit_post 50

This uses the development Jekyll environment by default, which overwrites site.url with http://localhost:4000 (instead of using https://www.jordanmerrick.com). The webmentions plugin then attempts to retrieve webmentions for posts under that URL, not my site's actual URL. As a result, no webmentions were being retrieved, so I couldn't test locally.

As a workaround, I discovered that I needed to set Jekyll's environment to production. This keeps site.url intact, allowing for webmentions to be properly retrieved:

JEKYLL_ENV=production bundle exec jekyll serve --limit_post 50

The plugin also supports sending webmentions, though I need to do a little more work to set that up. Outgoing webmentions is a separate command and not part of the build process. I do use a Digital Ocean instance for development, so I'm considering some sort of cronjob for handling outgoing webmentions.

Webmentions

  1. This seems so convoluted. Run Jekyll (or another static site generator) because dynamic platforms like WordPress are slow and bloated. But … now the website can’t support comments or Webmentions. So hook the site into a silo like Disqus or Webmention.io. But wait now your website is dependent on a third-party.

    Doesn’t it seem like we should be 100% independent?