I can now use Micropub to publish to my blog

I can now make use of Micropub to post on my blog!

More information:

I am in search for an easier way to blog from the go for quite some time now. Recently, I implemented a web-based form to submit new posts using the API of my self-hosted Gitea. While that worked, it was still not optimal.

I already heard of Micropub before, since I joined the IndieWeb, but I was always a bit scared of complexity to develop my own solution. So I searched instead for already existing solutions, which I could modify to better fit my custom requirements.

I found indiekit, which looked very promising, but it only supported Github. I am already using Gitea, so I would have had to change some of the JavaScript code.

After a bit more searching, especially for projects not written in PHP or JavaScript, I found gozette, which is written in Go. I’m quite familiar with and like Go for multiple reasons, so it was my perfect starting point. Although I rewrote like 80% of the code, until I was able to use it for my setup, I now have a Micropub endpoint for my Hugo blog. But not only that: Due to the rewrite I know the codebase and can easily add missing basic features, as well as more advanced features, I may need or want.

The code is public in a repository on Codeberg: hugo-micropub.

It is definitely not made as a generic solution, but it may be helpful for everyone needing a starting point or some inspiration themselves.

Compared to the original gozette I made the following significant changes:

Removed all dependencies and rewrote the HTTP handling with the Go standard library

Added support for Gitea and removed everything related to Github (seems like the Gitea API, or the one used endpoint, is actually much simpler than Github’s API)

Added support for multipart-data (some clients require this)

Added a custom hack to add a post to a content section using a prefixed category

Added another custom hack to also set a custom slug with clients that support categories, but not slugs (also done via adding a category with a specific prefix)

Adapted the post generation to my setup (YAML front matter instead of TOML etc.)

A lot more code restructuring etc.

My next planned steps include:

Adding support for posts without titles to my Hugo theme

Adding support for more post types including likes, replies, etc.

Adding a section for microblog interactions on my blog that isn’t shown on the homepage or in feeds

Automatic webmention sending after posting

In the end, after rewriting much of the code and actually reading parts of the Micropub specification, I found out, that Micropub isn’t as complicated as I feared earlier. Micropub is awesome!

Doing things like this is so interesting! Although it doesn’t have much practical value (I could just use a WordPress site and wouldn’t have all those problems), I’m learning a ton of new stuff and it’s just fun!

Interactions & Comments