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-pagesbranch 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 💜
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 👍