A modern, fast static site generator built with Bun and TypeScript. Features a powerful template engine, Markdown processing, and a beautiful design system.
🚀 Ultra-fast generation with Bun runtime
📝 Markdown support with frontmatter metadata
🎨 Modern design system with CSS variables
🏷️ Tag system with automatic tag pages
📱 Responsive design optimized for all devices
🔧 Custom template engine with loops, conditions, and helpers
⚡ Hot reloading during development
📊 Built-in pagination and archive pages
🌐 SEO optimized with proper meta tags
- Bun installed on your system
# Clone the repository
git clone https://github.com/yourusername/bun-static-site-generator.git
cd bun-static-site-generator
# Install dependencies
bun install# Build the site
bun run build
# Development with hot reload
bun run dev
# Serve the generated site
bun run servebun-static-site-generator/
├── content/ # Markdown content
│ ├── assets/ # Static assets (CSS, images)
│ ├── *.md # Blog posts and pages
│ └── a-propos.md # About page
├── templates/ # HTML templates
│ ├── partials/ # Reusable template parts
│ │ ├── header.html
│ │ └── footer.html
│ ├── default.html # Default page template
│ ├── post.html # Blog post template
│ ├── page.html # Static page template
│ └── index.html # Homepage template
├── dist/ # Generated site (output)
├── src/ # TypeScript source code
│ ├── types/ # Type definitions
│ ├── utils/ # Utility classes
│ └── generator.ts # Main generator
└── site.config.js # Site configuration
Create Markdown files in the content/ directory with frontmatter:
---
title: "My Blog Post"
description: "A short description"
date: 2024-01-15
author: "Your Name"
tags: ["javascript", "web-development"]
layout: "post"
---
# My Blog Post
Your content here...For static pages, use the page layout:
---
title: "About"
description: "About this site"
layout: "page"
---
# About
This is a static page.The template engine supports:
Variables:
{{ page.metadata.title }} <!-- Escaped HTML -->
{{{ content }}} <!-- Unescaped HTML -->Conditions:
{{ #if page.metadata.tags }}
<div class="tags">
<!-- Show tags -->
</div>
{{ /if }}Loops:
{{ #each page.metadata.tags }}
<span class="tag">{{ this }}</span>
{{ /each }}Helpers:
{{ formatDate page.metadata.date }}
{{ truncate page.metadata.description 120 }}
{{ join page.metadata.tags ", " }}Templates have access to:
page- Current page datasite- Site configurationpages- All pages arraycontent- Processed HTML content- Custom data passed to specific templates
Create a site.config.js file:
export default {
title: "My Site",
description: "My awesome static site",
author: "Your Name",
baseUrl: "https://mysite.com",
// Directories
contentDir: "./content",
templatesDir: "./templates",
outputDir: "./dist",
// Templates
defaultLayout: "default",
// Pagination
pagination: {
enabled: true,
postsPerPage: 10
}
};The design system uses CSS custom properties:
:root {
--primary-500: #667eea;
--gray-900: #18181b;
--space-4: 1rem;
--text-lg: 1.125rem;
--radius-md: 0.5rem;
}.container- Max-width container.post-card- Blog post card.article-header- Article header.tag- Tag styling.hero- Hero section
# Development with watch mode
bun run dev
# Build for production
bun run build
# Serve built site
bun run serve
# Clean build directory
bun run clean- Generator (
src/generator.ts) - Main site generation logic - Templates (
src/utils/templating.ts) - Template engine - Markdown (
src/utils/markdown.ts) - Markdown processing - FileSystem (
src/utils/fileSystem.ts) - File operations
Automatically generates pages for each tag at /tags/{tag}.html
Configure pagination in site.config.js:
pagination: {
enabled: true,
postsPerPage: 5
}Automatically finds related posts based on shared tags.
Auto-generated TOC for long articles:
<!-- In templates -->
{{{ toc }}}bun run buildThe generated site will be in the dist/ directory, ready for deployment to any static hosting service.
- Netlify - Drop the
distfolder - Vercel - Connect your repository
- GitHub Pages - Push
disttogh-pagesbranch - Any static host - Upload
distcontents
Extend the template engine in src/utils/templating.ts:
// Add to processHelpers method
case 'customHelper': {
const input = String(args[0] || '');
return input.toUpperCase();
}Create new templates in templates/ and reference them in frontmatter:
---
layout: "custom"
---Modify content/assets/style.css or add your own CSS files.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
MIT License - see LICENSE file for details.
- Initial release
- Markdown processing with frontmatter
- Template engine with loops and conditions
- Modern design system
- Tag system and pagination
- Development server with hot reload
Built with ❤️ using Bun