Custom output formats for Gemini and Hugo

I want to publish my blog with both the Gopher and Gemini protocols (as well as http/s of course).

I believe such lightweight protocols offer both gains for privacy (most user tracking technology is not supported) and for sustainability / energy-efficiency (the energy used by the internet contributes significantly to the greenhouse gas emissions fueling the climate crisis). One way I am trying to reduce the impact of my internet presence is by serving lightweight static websites generated by Hugo. I want to go a step further by also supporting minimalist protocols that go even further to reduce data transferred, server and client processing use, etc.

There are two primary reasons I am using Hugo:

  1. Inertia - I already use Hugo on some of my sites, so why learn a new static site generator?
  2. Custom output formats - Should enable publishing to Gopher and Gemini using the same static site generator. Note that according to Zola’s comparison chart, custom output formats are a feature that competitors like Zola and Pelican lack.

When I last posted about this, I was asking for official support. Certainly, adding Gopher and Gemini to the built-in output formats would help encourage adoption. And since I have not yet figured out how to serve Gopher and Gemini sites myself, it would be quite helpful to the development process if the Hugo server could serve Gopher+Gemini output as well as http/s. But official support is not necessary, and successfully using custom output formats would be a good first step.

I’ve linked to this post about generating Gopher sites with Hugo before, and I’m assuming that approach will still work.

What is new is that I’ve found an example of someone doing this for Gemini as well. Drew DeVault is publishing his Hugo blog to Gemini. He explains his process in a Gemini-exclusive post, which he also makes available on the web through an HTTP to Gemini proxy. You can browse his Hugo site’s source code if you’re curious.

So my first question is, has anyone in this forum successfully used custom output formats to publish to Gopher or Gemini? If so, do you have any tips, or sample code you can share?

Otherwise, I will do my best to implement these custom output formats as suggested in the above blog posts, and report back with my progress/issues.

6 Likes

Commenting on an old topic for others searching the forum for Gemini-related stuff:

I managed to follow a setup similar to ddevault’s on my blog: gemini://seirdy.one/ and https://seirdy.one/. I use custom gemtext and gemrss (an RSS feed) for Gemini alongside HTML.

Code: seirdy.one: Seirdy's personal website and gemini capsule

Some tips:

  1. You are probably not going to be able to auto-generate good Gemtext from Markdown, HTML, org-mode, or other featureful markup formats. Gemini links have their own line, so they serve a slight navigation purpose (like headings) as well. You might have to re-write some paragraphs to flow better with these breaks.

  2. You probably don’t have to put together an RSS/ATOM feed for Gemini these days, since lots of places support gmnisub. Just make your homepage feature a list of links in the same date+title format as most capsules and feed readers should parse it properly.

  3. Check the Gemini mailing list, of course ;).

2 Likes

I have come across this thread in the search for this exact problem. To add to possible solutions, I use the hugoext utility that pipes Hugo markdown content files through an arbitrary processing tool before recreating the hugo output directory structure with that output. There are several markdown to gemtext converters available. I use md2gmi as the hugoext processor.

This way I have no overhead in my hugo flow and just one extra command:

hugo --minify                   # html
hugoext -ext gmi -pipe md2gmi   # gemtext

To test it locally, I run gmifs before I publish it.

1 Like