Static, privacy-preserving embedding of Mastodon posts

Now that Mastodon is more of a thing, I thought I’d set up a static embed of Mastadon posts within Hugo, similar to what I did for Twitter posts.

With the static embedding, I wanted to remove all requirements for JavaScript, and remove all third-party requests on behalf of the users here. In short, this speeds things up, and saves you from worrying about cookies & tracking, or needing to make exceptions to the site’s CSP.

The downside is that it’s a cludge of bash script, JavaScript, Puppeteer, Go, and HTML on the backend. At least nobody else sees that.

It basically loads the embedded version of the post in Chromium, takes a time-stamped screenshot, extracts the post content, and creates an image embed with an alt-tag using a truncated part of the post content. And, links to the post for maximum PageRank, of course. The images & text content are stored in the site’s static directory, making serving easy.

Sample toot / post

John Mueller posted: Want to follow the world of #SEO ? Click the hashtag and follow it. That way it shows content from across servers, which seems like a useful thing (until it's full of SEO #spam ,  ...
View post

Full code is on Github.

Comments / questions

There's currently no commenting functionality here. If you'd like to comment, please use Mastodon and mention me ( @hi@johnmu.com ) there. Thanks!

Related pages