v0.1.1 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2021 License: GPL-3.0 Imports: 13 Imported by: 0



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. 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 in that dir. If there's no matching template or no, 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

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

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

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

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL