A high-performance HTTP server written in Go featuring a modern blog system with markdown support, server-side template rendering, and embedded assets.
This project demonstrates best practices for building scalable web applications in Go, including middleware chain implementation, configuration management, and full-featured content management capabilities.
The server serves HTML views, static assets, and a comprehensive API surface with pagination support for blog content.
Requirements:
- Go 1.26+
Build:
make buildRun:
make runThis project supports .env file (loaded automatically) and a few command-line flags.
- Environment file: copy
.env.example→.envand edit values. - Flags (highest priority):
-host(default0.0.0.0)-port(default8000)-resources(path served at/resources/for large files)-serve(addional path served at/)-version(prints binary version)
.env variables (examples in .env.example): HOST, PORT ...
blog/, views/, static/, and public/ are embedded into the binary via assets.go. The server always serves those embedded files at runtime; to change the content, edit the files under their respective folders and rebuild the binary.
- GET
/- home page with latest 5 blog posts (paginated) - GET
/blog/- blog listing page with latest 10 posts (paginated) - GET
/blog/{date}/{slug}- individual blog post page - GET
/*- additional path served at/route set by-serve - GET
/*- public assets served at/route - GET
/static/*- static assets - GET
/health- health check (JSON) - GET
/ready- readiness check (JSON) - GET
/resources/*- served from the path set by-resources - GET
/robots.txt
Templates are located in views/ and include:
layout.html— base layoutmeta.html— PWA/meta includeshome.html— home page with latest 5 blog postsabout.html- simple about pageblog_list.html— blog listing pageblog_post.html— individual blog post pagenot_found.html— 404 error page
This server includes a full-featured blog system with markdown support and YAML frontmatter.
Blog posts are markdown files located in the blog/ directory with optional YAML frontmatter:
---
title: My Post Title
excerpt: A short summary of the post
author: Author Name
license: CC BY-SA
createdAt: 2024-01-15
keywords: [tag1, tag2, tag3]
---
Your markdown content here...slug— URL-friendly identifier (defaults to filename without.md)title— Post heading (defaults to slug in Title Case)excerpt— Short summary (defaults to first 160 characters of content)author— Single author string or array of authors (defaults to "Anonymous")license— Content license (defaults to "CC BY-SA")createdAt— Publication date (defaults to file creation time)updatedAt— Update date (defaults to file modification time)published— Draft/live status, boolean (defaults to true)keywords— Comma-separated tags for SEO (optional)image— Featured image URL/path (optional)image_alt— Alt text for featured image (optional)reading_time— Auto-calculated from word count, not manually specified
Blog posts support advanced markdown features via GFM extensions:
- Tables
- Strikethrough
- Task lists
- Footnotes
- Definition lists
- Auto-linking
- Typographic enhancements
- Auto-generated heading IDs for anchor links
Reading time is automatically calculated based on word count.
MIT License