modulepackage
0.9.2
Repository: https://github.com/zacxdev/go-static-site.git
Documentation: pkg.go.dev
# README
Go Static Site
The one-file declarative static site generator. Define your site routes/sources in a single manifest file.
Introduction
Go Static Site is designed with simplicity in mind - we believe configuring your static site should be as straightforward as describing it. By using a single YAML manifest file, you can define your entire site structure, including routes, templates, JavaScript bundles, and translations. No more memorizing magic directory layouts or file naming patterns.
Features
- πΊοΈ Single file configuration
- π i18n enabled by default
- π¦ JavaScript transpilation and injection using checksums to enable heavy caching without risk of serving stale code
- ποΈ Template rendering with Plush
- Partial injection for simple modular and reusable component templates
- βοΈ Markdown support with frontmatter
- πΊοΈ Automatic sitemap generation
- π Development server with hot reloading (coming soon)
- π± Static site generation for production
Stack
- Go: Core runtime and static site generation
- Plush: Template engine for HTML templates
- esbuild: JavaScript bundling and optimization
- Markdown: Content authoring with frontmatter support
- Gorilla Mux: Routing
- YAML: Configuration format
Quick Start
- Install the generator:
go install github.com/yourusername/go-static-site@latest
- Create a
manifest.yaml
file in your project root:
origin: https://mysite.com
partials:
header:
source: "templates/partials/header.plush.html"
template_type: "PLUSH"
routes:
- path: /
source: pages/home.plush.html
template_type: PLUSH
partial_deps:
- header
javascript_deps:
- main
- path: /blog/:slug
source: pages/blog/[slug]/[lang].md
template_type: MARKDOWN
partial_deps:
- header
javascript_deps:
- blog
javascript:
main:
source: src/main.ts
out_dir: static/js
blog:
source: src/blog.ts
out_dir: static/js
translations:
- code: en
source: translations/en.yaml
source_type: YAML
- code: es
source: translations/es.yaml
source_type: YAML
not_found_page_source: pages/404.plush.html
- Start the development server:
go-static-site serve
- Build for production:
go-static-site build
Project Structure
your-project/
βββ manifest.yaml
βββ pages/
β βββ home.plush.html
β βββ blog/
β β βββ my-post/
β β βββ en.md
β β βββ es.md
β βββ 404.plush.html
βββ src/
β βββ main.ts
β βββ blog.ts
βββ static/
β βββ css/
β βββ styles.css
βββ templates/
β βββ layouts/
β βββ base.plush.html
βββ translations/
βββ en.yaml
βββ es.yaml
Configuration
Routes
Routes can be static or dynamic:
- Static routes:
/about
,/contact
- Dynamic routes:
/blog/:slug
,/products/:id
- Language-specific routes are automatically generated based on your translations
JavaScript Bundling
- Uses esbuild for blazing fast bundling
- Automatic file hashing for cache busting
- Bundles are specified in the manifest and can be referenced in routes
Templates
Two template types are supported:
PLUSH
: HTML templates with Go's Plush templating engineMARKDOWN
: Markdown files with YAML frontmatter
Translations
- YAML-based translation files
- Automatic language route generation
- Translation helper available in templates:
<%= text("key") %>
Markdown Frontmatter
title: My Blog Post
description: A great post about things
---
# Content starts here
Your markdown content...
Development
# Start development server
go-static-site serve -p 9010
# Build static site
go-static-site build
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT
# Packages
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author