Temple is a minimal, concurrent static site generator that transforms Markdown notes into HTML pages. Built with Go’s excellent templating package and a couple of other packages, it offers a (limited) lightweight alternative to heavier tools like Hugo. I use Temple as the templating engine for the notes on my website.
- Markdown parsing (using goldmark) and conversion to HTML (with YAML frontmatter support)
- Syntax highlighting for code blocks using chroma
- Custom HTML templates using go's html/template
- Concurrent processing of notes
- Deduplicated CSS output for the syntax highlighting
- Go 1.16 or later
- Python 3 (for serving the generated files)
- Clone the repository:
git clone https://github.com/guychouk/tmpl.git
cd tmpl- Build the project:
make buildTo generate HTML files from your Markdown notes:
./tmpl --output ./public --templates ./src/templates.html notesThe project includes a Makefile with several useful commands:
make build- Build the projectmake clean- Remove build artifacts and generated filesmake serve- Serve the generated files using Python's built-in HTTP servermake all- Build and serve in one command
- Build the project:
make build- Generate HTML files:
./tmpl --output ./public --templates ./src/templates.html notes- Serve the generated files:
make serveThen visit http://localhost:8000 in your browser to see the generated site.
.
├── main.go # Main program
├── Makefile # Build and serve commands
├── notes/ # Your Markdown notes
├── public/ # Generated HTML files
└── src/
└── templates.html # HTML templates
All tmpl does is it reads a directory with Markdown files, maps each .md file to a Note struct, reads the HTML templates defined in the provided file, and finally generates HTML files along with a CSS file for syntax highlighting in code blocks.
Each note is expected to have a YAML frontmatter with the following fields:
---
title: A meaningful title
date: YYYY-MM-DD
---
your note here - The program reads Markdown files from the specified directory
- Each file is processed concurrently:
- Markdown is converted to HTML
- YAML frontmatter is extracted
- Syntax highlighting CSS is collected
- HTML files are generated using the provided templates
- A single, deduplicated CSS file is created for syntax highlighting
- goldmark - Markdown parser
- chroma - Syntax highlighting
- html/template - HTML templating
This project is licensed under the MIT License - see the LICENSE file for details.