Cross-posting RSS to Mastodon
Here are the steps I had to take to set up cross-posting from this blog to Mastodon. The format is a little rough, but hopefully it will help someone.
I did this on my Debian server, but it should work with any RSS feed on any server that can run python.
- Install feed2toot
- Install via pip:
- Make sure you have python3 and python3-pip installed
apt-get install python3 python3-pip
- Install the feed2toot script
pip3 install feed2toot
- Make sure you have python3 and python3-pip installed
- Install via git. This is what I ended up doing because I made some modifications to the script (more on that below)
git clone git@gitlab.com:mplorentz/feed2toot.git
- Install via pip:
- Connect feed2toot to Mastodon by running the following command:
register_feed2toot_app
- Create your configuration file. This allows you to customize the behavior of feed2toot. You can find the default configuration and a full list of options here. In the file you will want to:
- Change
toot_visibility
topublic
(Once you have tested it) - Paste your RSS feed URL into the
uri
field.
- Change
- Test it. These commands will perform a dry run - they will not actually post any toots to Mastodon.
- If you installed via pip:
feed2toot -c feed2toot.ini -nv
- If you installed via git:
python3 feed2toot.py -c feed2toot.ini -nv
- If you installed via pip:
- If things look good, you may want to go ahead and tell feed2toot to populate the cache. This prevents it from posting everything in your RSS feed the first time you run it for real. You can do this by running
feed2toot -c feed2toot.ini -p
. - Run feed2toot on a schedule.
- I added the following line to my crontab to run the script every minute:
* * * * * /usr/bin/python3 /path/to/feed2toot.py -c feed2toot.ini
- Don’t forget to change
toot_visibility
topublic
in your configuration file if you didn’t already. Otherwise no one will see your toots!
- I added the following line to my crontab to run the script every minute:
- (Optional) Configure feed2toot to only toot micro posts.
- I have an open merge request to support filtering items in the RSS feed based on a tag. For now you will need to install my fork of feed2toot using the git instructions above if you wish to use this feature.
- Change the
toot
line in your configuration file to this:toot={summary}
. This instructs feed2toot to post the content of your micro post instead of the title and a link.
- Add the following two lines in the
[rss]
section:tags_pattern={tag_name}
where “{tag_name}” is the tag that you use for your micro posts. On my Jekyll blog I tag all my micro posts with the “micro” tag, so my configuration file saystags_pattern=micro
.tags_pattern_case_sensitive=false
- Change the
- I have an open merge request to support filtering items in the RSS feed based on a tag. For now you will need to install my fork of feed2toot using the git instructions above if you wish to use this feature.
- (Optional) Configure feed2toot to strip HTML out of your content
- My Jekyll blog includes HTML tags in the RSS feed fields. Feed2toot does not strip these tags out by default, so I opened a merge request to change that. If you install my fork of feed2toot using the git instructions above then you get this feature free of charge :)
And that’s it! I can now make a micro-post on my own blog, and it will show up in my RSS feed, on micro.blog, and Mastodon. I’d like to set up another instance of feed2toot that will post links to regular blog posts, but that’s a task for another day.