π οΈ Leafy: Minimal Static Site Generator
Leafy is a minimal static site generator written in Go. It enables the rapid creation of a basic HTML site by processing Markdown content against an HTML template.
π Requirements
- Go 1.20+ installed on your system.
- Basic knowledge of Markdown and HTML/Go Templates (
.tmpl).
π Installation
Install the latest version of the Leafy binary:
go install github.com/LazyCode2/leafy@latest
βοΈ Usage Guide
1. Initialize Project Structure
Run the following command in your desired project directory to create the necessary structure:
leafy --init
This command creates the following required directory structure:
βββ content/ (For Markdown files)
βββ output/ (Generated HTML site destination)
βββ template/ (For Go template files)
2. Add Content
Place your Markdown source file in the content folder.
π Example Content Folder
content/
βββ _index.md # Homepage content
βββ about.md # Example page
βββ contact.md # Another example page
3. Define Template
Create your HTML template file inside the template folder (e.g., template/default.tmpl).
The template must include the {{ .Data }} placeholder where the processed Markdown content will be inserted.
Example Template (template/default.tmpl):
<!DOCTYPE html>
<html>
<head>
<title>{{ .Title }}</title>
</head>
<body>
<h1>My Static Site</h1>
{{ .Data }}
</body>
</html>
Example Index Template (template/index.tmpl):
<!DOCTYPE html>
<html>
<head>
<title>{{ .Title }}</title>
</head>
<body>
<h1>My Static Site</h1>
{{ .Data }}
</body>
</html>
4. Build Site
Generate the final HTML file by executing the build command:
leafy --build
The resulting HTML file (index.html) will be placed in the output/ directory.