Will's avatar

⬅️ See more posts

Cross-publishing web content to Gemini

1 June 2023 (2 minute read)

🔮 This post is also available via Gemini.

technology gemini

Capsules floating in space

My personal website is generated using Hugo, which allows me to write nearly all of the actual content itself in plain markdown files.

I also maintain a Gemini capsule (hosted at gemini://wilw.capsule.town). For a while I’ve wanted to be able to add more content to this capsule, and to try and keep it updated more consistently over time. However, I don’t really have the capacity to duplicate the time taken to maintain the site (and its blog posts and notes) in order to do so.

Whilst Gemini text format is not markdown, it is similar enough that I wondered if I could script a simple translation flow to turn my *.markdown files into valid .gmi ones.

At the end of the day, it is up to the Gemini clients themselves to decide how to render content, and so the main thing I really needed to handle were links (which can’t be rendered in-line in Gemini) and images (which cannot be displayed).

Using the python-frontmatter package, I was able to write a quick builder script which now helps to populate my Gemini capsule.

The script creates new Gemini files for each of my blog posts and notes, and also generates index files to allow navigation to this content. In each file, links are extracted out of the main text, and replaced with indexed references (e.g. [3]), which are then placed as valid Gemini links after each paragraph.

If an article has links referencing another blog post or note, then the links are generated using the gemini:// protocol, allowing the visitor to stay in Gemini as much as possible.

The script is executed as part of my Woodpecker CI pipeline to automate the generation of the Gemini capsule on each git push. The output is then automatically deployed to gemini://capsule.town in order to make the changes live.

It’s great knowing that I can now keep the capsule up-to-date as part of my usual workflow.

✉️ You can reply to this post via email.

📲 Subscribe to updates

If you would like to read more posts like this, then you can subscribe via RSS.