💾 Archived View for nox.im › projects › hugoext captured on 2023-07-10 at 13:44:28. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-04-26)
-=-=-=-=-=-=-
Hugo output processor extensions - hugoext source code on Github[1].
1: hugoext source code on Github
If you have the go tool chain installed, you can install and try gmifs with:
go install github.com/n0x1m/hugoext@latest
Before I started this utility program, I've read several articles online on what people are doing to host their Gemini capsule alongside a hugo blog. None of the solutions were satisfying to me. I needed something that works just like the hugo command, outputs the same directory tree with `.gmi` versions of the markdown files. I also only found a python markdown to gemtext converter available.
So in the end I started md2gmi[1] first. Both tools md2gmi and hugoext work on their own and have no dependencies on one another, but they're composable for my needs instead and work together. Before it was ready I then skimmed the hugo source tree on what functions are available to do these things:
- create permalinks
- read the config to learn about permalink settings, ugly urls and draft settings
- read markdown and provide the front matter in a map or struct
The latest hugo version sadly seems very convoluted and tightly coupled, requiring me to jump from package to package. Only (and luckily) the config parser was readily available, allowing me to just import that package with Go. As for parsers of the other requirements I gave up (possibly too early?) and exported a page parser and a permalink generator from the hugo@v0.49.2 tree from 2018. I didn't spend too much time on this but rather was looking for a version that had easily exportable functions for me to use. hugoext ships with 3 files from that source tree, slightly modified and extended. Combining these was relatively straightforward and I could just add some file tree parsing on top.
I didn't add any template parsing so far and just generate a list per section with the available content items. It's good enough for me now but feel free to submit pull requests if you want additional features. I was at first thinking of adding a file watcher, but I seldomly use this feature with hugo.
Note that I have uglyURLs off for both hugo and gemini. With pretty URLs (index files in dierctories in the paths) the URLs between the web and the gemini version of this blog look the same.
The output of hugoext can immediately served with the `gemfs` command. See the gmifs[1] Gemini file server.