1
0
Fork
You've already forked gomdn
0
Yet antoher static site generator: Markdown to HTML
  • Go 84.7%
  • HTML 11.9%
  • Makefile 3.4%
2025年08月24日 21:49:13 +02:00
LICENSES Initial 2025年07月22日 17:52:16 +02:00
test Initial 2025年07月22日 17:52:16 +02:00
go.mod Initial 2025年07月22日 17:52:16 +02:00
go.sum Initial 2025年07月22日 17:52:16 +02:00
LICENSE Initial 2025年07月22日 17:52:16 +02:00
main.go Initial 2025年07月22日 17:52:16 +02:00
Makefile Initial 2025年07月22日 17:52:16 +02:00
README.md Use a template not using the now non-existing .stylesheet variable 2025年08月24日 21:49:13 +02:00
REUSE.toml Initial 2025年07月22日 17:52:16 +02:00
template.html Use a template not using the now non-existing .stylesheet variable 2025年08月24日 21:49:13 +02:00

gomdn

A simple static site generator in Go. There are many like it, but this one is mine.

It uses CommonMark Markdown but with the first row as the H1 and title of the document.

Rows starting with ; are ignored and can be used as comments or to set up your editor.

Since this is slightly non-standard Markdown the default suffix of the source files is .mdu rather than .md.

Usage

Please note: A file called template.html must either exist in the directory where you run gomdn or passed to it by -t /path/to/template.html.

Convert all files with a .mdu suffix in this directory and recursively downwards to HTML, copying all the other files, not ending with .mdu. The resulting files, generated and copied, end up in the directory public:

gomdn src

If the target file already exists and has a timestamp later than the .mdu file, that file is skipped.

% gomdn -h
Usage of /home/mc/shared/hacks/gomdn/gomdn:
 -f force generation of target
 -o string
 output directory (default "public")
 -s string
 suffix of the Markdown file (default ".mdu")
 -t string
 path to template file (default "template.html")
 -u allow HTML in source
 -v Be more verbose

Template

The template follows the html/template style of Go. The following variables are available:

  • {{.title}}: The title from the first row of the .mdu file.
  • {{.html}}: The generated HTML.

Example template using both variables:

<!DOCTYPE html>
<html>
<head>
 <meta charset="utf-8">
 <meta name="viewport" content="width=device-width,
 initial-scale=1.0, user-scalable=yes,
 shrink-to-fit=no">
 <link rel="stylesheet" type="text/css" href="/~mc/nav.css">
 <title>{{.title}}</title>
</head>
<body>
 <nav>
 <a href="/~mc/">Home</a> |
 <a href="/~mc/bio.html">About</a> |
 <a href="/~mc/now.html">Now</a> |
 <a href="/~mc/writings.html">Writings</a> |
 <a href="/~mc/blog/">Blog</a> |
 <a href="/~mc/projects/">Projects</a> |
 <a href="/~mc/contact.html">Contact</a>
 </nav>
<h1>{{.title}}</h1>
{{.html}}
</body>
</html>

Note that you can point to a stylesheet in the template.

Place this file in the top directory where you are going to run gomdn.

History

This replaces a Perl script I wrote many, many years ago that I used with the original Markdown.pl and make to generate my web pages. This program replaces all three.