Documentation

Overview

gmnhg converts Hugo content files to a Gemini site. This program is to be started in the top level directory of a Hugo site (the one containing config.toml).

gmngh will read layout template files (with .gotmpl extension) and then apply them to content files ending with .md by the following algorithm (layout file names are relative to gmnhg/):

1. If the .md file specifies its own layout, the relevant layout file is applied. If not, the default template is applied (single). If the layout file does not exist, the file is skipped. Draft posts are not rendered. _index.md files are also skipped.

2. For every top-level content directory an index.gmi is generated, the corresponding template is taken from top/{directory_name}.gotmpl. Its content is taken from _index.gmi.md in that dir. If there's no matching template or no _index.gmi.md, the index won't be rendered.

3. The very top index.gmi is generated from index.gotmpl and top-level _index.gmi.

The program will then copy static files from static/ directory to the output dir.

Templates are passed the following data:

1. Single pages are given .Post, which contains the entire post rendered, .Metadata, which contains the metadata crawled from it (see HugoMetadata), and .Link, which contains the filename relative to content dir (with .md replaced with .gmi).

2. Directory index pages are passed .Posts, which is a slice over post metadata crawled (see HugoMetadata), .Dirname, which is directory name relative to content dir, and .Content, which is rendered from directory's _index.gmi.md.

3. The top-level index.gmi is passed with the .PostData map whose keys are top-level content directories names and values are slices over the same post props as specified in 1, and .Content, which is rendered from top-level _index.gmi.md.

This program provides some extra template functions, documented in templates.go.

One might want to ignore _index.gmi.md files with the following Hugo config option in config.toml:

ignoreFiles = [ "_index\\.gmi\\.md$" ]