Skip to content

bmf-san/gohan

gohan

CI Go Reference License: MIT

A simple, fast static site generator written in Go — featuring incremental builds, syntax highlighting, Mermaid diagrams, and a live-reload dev server.

日本語版: README.ja.md

gohan

This logo was created by gopherize.me.


Features

  • Incremental builds — Regenerate only changed files, minimising build time
  • Markdown + Front Matter — GitHub Flavored Markdown with YAML metadata
  • Syntax highlighting — Code blocks styled with chroma
  • Mermaid diagrams — Fenced + "" + mermaid + "" + blocks render as interactive diagrams
  • Taxonomy — Tag and category pages generated automatically
  • Atom feed & sitemapatom.xml and sitemap.xml generated automatically
  • Live-reload dev servergohan serve watches files and reloads the browser
  • Customisable themes — Full control via Go html/template- Plugin system — Built-in plugins enabled per-project via config.yaml (no Go code required)

Installation

go install github.com/bmf-san/gohan/cmd/gohan@latest

Or build from source:

git clone https://github.com/bmf-san/gohan.git
cd gohan
make install

Pre-built binaries are available on GitHub Releases.


Quick Start

# 1. Create a project directory
mkdir myblog && cd myblog

# 2. Add config.yaml (see docs/guide/configuration.md for all options)
cat > config.yaml << 'EOF'
site:
  title: My Blog
  base_url: https://example.com
  language: en
build:
  content_dir: content
  output_dir: public
theme:
  name: default
EOF

# 3. Create your first article
gohan new post --slug=hello-world --title="Hello, World!"

# 4. Build the site
gohan build

# 5. Preview locally with live reload
gohan serve   # open http://127.0.0.1:1313

Plugins

Plugins are compiled into gohan and toggled via config.yaml. No Go code is required to use them.

amazon_books

Generates Amazon book card data (cover image, product URL, title) from ASIN values in an article's front-matter. Designed for affiliate link integration.

config.yaml:

plugins:
  amazon_books:
    enabled: true
    tag: "your-associate-tag-22"   # Amazon Associates tracking tag

Article front-matter:

books:
  - asin: "4873119464"
    title: "Learning Go"   # optional; used for alt text

Template usage (in your theme's article.html):

{{with index .PluginData "amazon_books"}}
{{if .books}}
<section class="book-cards">
  {{range .books}}
  <a href="{{.LinkURL}}" target="_blank" rel="noopener">
    <img src="{{.ImageURL}}" alt="{{.Title}}">
    <span>{{.Title}}</span>
  </a>
  {{end}}
</section>
{{end}}
{{end}}

See docs/DESIGN_DOC.md §20 for the full plugin architecture.


User Guide

Guide Description
Getting Started Installation, first site, build & preview
Configuration All config.yaml fields and Front Matter
Templates Theme templates, variables, built-in functions
Taxonomy Tags, categories, and archive pages
CLI Reference All commands and flags

Design

For architecture and design decisions see docs/DESIGN_DOC.md.


Contributing

See CONTRIBUTING.md for development setup and contribution guidelines.


Sponsor

If you'd like to support my work, please consider sponsoring me!

GitHub Sponsors – bmf-san

Or simply giving ⭐ on GitHub is greatly appreciated—it keeps me motivated to maintain and improve the project! :D


License

MIT

About

A simple, fast static site generator written in Go with differential builds

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Contributors