Creating a static Mastodon user’s archive

The current (4.0.2) Mastodon profile page is bad. Bad because it requires JavaScript to load. If you want to go back in time and look at your own posts it's not convenient, it's just slow.

I find myself wanting to find old posts to re-share or revisit often. So I decided to first build a sitemap.xml to send to Google. The idea was to leverage Google's search engine powers to find my old posts πŸ€” But that is not guaranteed to be indexed. So, it's no good πŸ™…β€β™‚οΈ

βœ‹ Before you say "install Elastic Search" in your instance. I just don't want to do that ☹️ It feels overkill for a single-user instance when I have less than a thousand posts (at the time of this writing).

πŸ’‘ Creating a static HTML with all the posts

What does this repo do?

  • Uses the great Mastodon.py script that allows you to connect to an instance (using an access token created from the Mastodon preferences > Development).
  • Uses a very small python script to loop through the posts and generate a simple HTML.
  • It has a GitHub Actions build file that runs every night.
  • The HTML output is then sent to a gh-pages branch to be hosted for free on GitHub Pages.

It's all automatic and I get a simple HTML page with all my posts for each search.

It's fantastic 🀩 (here's the live archive).

I don't know Python but I took advantage of GitHub Copilot to do most of the modifications and fix issues for me 😁

Feel free to fork it and amend it to your needs πŸ’œ

➑️ https://github.com/quicoto/mastodon-archive

What's next?

You could, if you wanted do more stuff with the HTML page, create secondary pages by hashtag or some sort of other filters (should you have too many to fit in a single page).

For me, this implementation is good enough, all posts on a single page that renders fast and it's easy to search πŸ‘

Comments

Reposts

  • James P. :arch_linux: :firefox: :sway: :xfce:
  • Daniel Schildt

Leave a Reply

Your email address will not be published. Required fields are marked *