GoBlog

module
v2.5.0-beta1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2026 License: MPL-2.0

README

GoBlog

Go Reference Go Report Card Test DockerHub

GoBlog is a blog generation and serving system for creating static blog feeds from Markdown files. It is available as a CLI tool, a Docker image, and an embeddable Go library.

CLI

Install the goblog binary:

go install github.com/harrydayexe/GoBlog/v2/cmd/goblog@latest
# Generate static files
goblog generate posts/ output/

# Serve locally
goblog serve posts/
generate flags
Flag Short Default Description
--raw -r false Output raw HTML without template wrapping
--disable-tags -T false Disable tag tracking and tag page generation
--disable-reading-time false Disable reading time estimation on posts
--root-path -p / Blog root path for subdirectory deployment
--template-dir -t built-in Path to a custom template directory
serve flags
Flag Short Default Description
--port -P 8080 TCP port to listen on
--host -H all interfaces Host address to bind to
--disable-tags -T false Disable tag tracking and tag page generation
--disable-reading-time false Disable reading time estimation on posts
--root-path -p / Blog root path for subdirectory deployment
--template-dir -t built-in Path to a custom template directory

Docker

The official image is harrydayexe/goblog. It runs goblog serve /posts by default and exposes port 8080.

Mount your Markdown posts directory to /posts:

docker run -v ./posts:/posts -p 8080:8080 harrydayexe/goblog

Pass any serve flags after the image name — re-supply the posts path as the first argument:

docker run -v ./posts:/posts -p 9000:9000 harrydayexe/goblog /posts --port 9000
docker run -v ./posts:/posts -p 8080:8080 harrydayexe/goblog /posts --root-path /blog/

For custom templates, mount your template directory and use --template-dir:

docker run \
  -v ./posts:/posts \
  -v ./mytheme:/mytheme \
  -p 8080:8080 \
  harrydayexe/goblog /posts --template-dir /mytheme

Library

Add GoBlog as a dependency:

go get github.com/harrydayexe/GoBlog/v2

The main packages are:

Package Summary
pkg/parser Parse Markdown + YAML frontmatter into Post objects
pkg/generator Convert a posts directory into a GeneratedBlog in memory
pkg/outputter Write a GeneratedBlog to disk or a custom destination
pkg/server Embeddable HTTP server with atomic live-reload
pkg/config Functional options for generator, outputter, and server
pkg/models Core data types: Post, PostList, template data structs
pkg/templates Embedded default templates (templates.Default)

A minimal generate-and-write example:

package main

import (
    "context"
    "os"

    "github.com/harrydayexe/GoBlog/v2/pkg/generator"
    "github.com/harrydayexe/GoBlog/v2/pkg/outputter"
    "github.com/harrydayexe/GoBlog/v2/pkg/templates"
)

func main() {
    fsys := os.DirFS("posts/")
    renderer, err := generator.NewTemplateRenderer(templates.Default)
    if err != nil {
        panic(err)
    }

    gen := generator.New(fsys, renderer)
    blog, err := gen.Generate(context.Background())
    if err != nil {
        panic(err)
    }

    writer := outputter.NewDirectoryWriter("output/")
    writer.HandleGeneratedBlog(context.Background(), blog)
}

Full API documentation, including all config options and template data types, is at pkg.go.dev/github.com/harrydayexe/GoBlog/v2.

Contributing

Contributions are welcome. See CONTRIBUTING.md for how to set up the project, run tests, and submit pull requests.

License

GNU General Public License v3.0 — see LICENSE for details.

Directories

Path Synopsis
cmd
goblog command
internal
errors
Package errors provides error handling utilities with colored terminal output for the CLI.
Package errors provides error handling utilities with colored terminal output for the CLI.
logger
Package logger provides CLI logging with colored output using slog.
Package logger provides CLI logging with colored output using slog.
utilities
Package utilities provides helper functions for CLI input validation and error handling.
Package utilities provides helper functions for CLI input validation and error handling.
pkg
config
Package config provides common configuration options used across the GoBlog generator and outputter packages.
Package config provides common configuration options used across the GoBlog generator and outputter packages.
generator
Package generator provides functionality for generating static HTML blog sites from markdown files.
Package generator provides functionality for generating static HTML blog sites from markdown files.
models
Package models provides data structures for representing blog posts and collections.
Package models provides data structures for representing blog posts and collections.
outputter
Package outputter provides interfaces and implementations for handling generated blog content from the generator package.
Package outputter provides interfaces and implementations for handling generated blog content from the generator package.
parser
Package parser reads markdown files with YAML frontmatter and converts them to Post objects for the GoBlog system.
Package parser reads markdown files with YAML frontmatter and converts them to Post objects for the GoBlog system.
server
Package server provides an HTTP server for serving generated blog content with support for live content updates via atomic handler hot-swapping.
Package server provides an HTTP server for serving generated blog content with support for live content updates via atomic handler hot-swapping.
templates
Package templates provides embedded default templates for the GoBlog system.
Package templates provides embedded default templates for the GoBlog system.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL