Announcing Blog Posts automatically on Mastodon

Apr 25, 2024

tech Website

Reading time: 2 minutes

Recently I came across a Post by Kev Quirk where he talks about how he uses a service called “Echo Feed” to cross post his blog posts to Mastodon. I had thought about implementing something like this too for a while, and this gave me the motivation to look into it again.

But I didn’t want to subscribe to a service, and I also didn’t want to self host this, because it sounded a bit complicated, so I went looking for a simpler solution.

After a bit of googling I found “feediverse”, which does exactly what I want: It consumes the RSS feed of my site and posts new posts to Mastodon. And it’s just a python script that I can run locally. Perfect.

So I installed it on my server (using pipx, which is awesome as it takes care of dependencies and creates a virtual Python environment).

On first run it asks for your Mastodon credentials, registers to Mastodon, asks for the URL to your feed and that’s it. It creates a config file in the home directory called .feediverse where all relevant info is stored. No on every run it parses the RSS feed and posts new items to Mastodon.

The only thing I adapted slightly was the “template” line in the config file, so I could get line breaks and a hashtag in the Mastodon post. The line in question is:

- template: "New blog post: \n\n{title} \n{url} \n\n#phloggersgarage"

Feediverse can also add hashtags from the blog post to the Mastodon post automatically, but I haven’t looked into that any further.

But that’s it already. I put a line in my crontab to run the program once every hour like so:

@hourly /home/ak/.local/bin/feediverse

And now with any luck a post about this post will appear on Mastodon without me having to do anything at the next full hour. Let’s see!