No description
  • Go 54.9%
  • CSS 26.3%
  • HTML 17.1%
  • Dockerfile 1.7%
Find a file
2026-03-09 19:53:19 +08:00
csrf Initial commit 2026-03-09 19:53:19 +08:00
db Initial commit 2026-03-09 19:53:19 +08:00
handlers Initial commit 2026-03-09 19:53:19 +08:00
mail Initial commit 2026-03-09 19:53:19 +08:00
session Initial commit 2026-03-09 19:53:19 +08:00
static Initial commit 2026-03-09 19:53:19 +08:00
templates Initial commit 2026-03-09 19:53:19 +08:00
.env.example Initial commit 2026-03-09 19:53:19 +08:00
docker-compose.yml Initial commit 2026-03-09 19:53:19 +08:00
Dockerfile Initial commit 2026-03-09 19:53:19 +08:00
go.mod Initial commit 2026-03-09 19:53:19 +08:00
main.go Initial commit 2026-03-09 19:53:19 +08:00
README.md Initial commit 2026-03-09 19:53:19 +08:00

☰ Marblogue006

A minimalist, self-hosted blog — single-user by default, multi-user capable.
Built with plain Go, MariaDB, Docker Compose, and a Material You design.
Licensed under CC0 (public domain).


Features

  • Markdown posts — write in Markdown, rendered to HTML
  • Post grid — cover image or first-letter preview fallback
  • Light/dark theme — follows OS preference, manual override available
  • Admin panel — write, edit, delete posts with a live Markdown editor
  • Session auth — HMAC-signed cookie sessions, no extra dependencies
  • SMTP with fallback — primary + secondary SMTP server support
  • Docker Compose — one command to run everything
  • Beginner-friendly code — comments throughout explain each step

Quick Start

1. Clone or extract the project

cd marblogue006

2. Set up your environment

cp .env.example .env
nano .env   # Fill in your values

Key things to change in .env:

  • DB_PASSWORD and DB_ROOT_PASSWORD — use strong passwords
  • SESSION_SECRET — run openssl rand -base64 32 to generate one
  • ADMIN_USER / ADMIN_PASS — your blog login credentials
  • SMTP settings if you want email features

3. Start with Docker Compose

docker compose up -d

This will:

  1. Pull and start MariaDB
  2. Build and start the Go app
  3. Create the database tables automatically
  4. Create your admin user (from ADMIN_USER / ADMIN_PASS)

Visit: http://localhost:8080

4. Log in and write your first post

Go to http://localhost:8080/login and log in with your admin credentials.
Then go to http://localhost:8080/admin and click New Post.


Project Structure

marblogue006/
├── main.go                  Entry point — routes and server startup
├── db/db.go                 Database connection, migration, admin seeding
├── session/session.go       HMAC-signed cookie sessions
├── mail/mailer.go           SMTP email with primary + fallback
├── handlers/
│   ├── handler.go           Base handler, template rendering, helpers
│   ├── auth.go              Login and logout
│   ├── posts.go             Homepage grid + single post view
│   └── admin.go             Admin panel: create, edit, delete posts
├── templates/
│   ├── base.html            Base layout (navbar, footer, theme toggle)
│   ├── index.html           Homepage post grid
│   ├── post.html            Single post view
│   ├── login.html           Login form
│   └── admin/
│       ├── dashboard.html   Admin post list
│       └── edit.html        Post editor (create + edit)
├── static/
│   └── style.css            Material You CSS (light + dark, responsive)
├── Dockerfile               Multi-stage Go build
├── docker-compose.yml       App + MariaDB orchestration
└── .env.example             Configuration template

Running Locally (without Docker)

You need Go 1.21+ and a MariaDB instance.

# Install dependencies
go mod download

# Set env vars (or export them manually)
export DB_HOST=localhost DB_PORT=3306 DB_NAME=marblogue
export DB_USER=marblogue DB_PASSWORD=secret
export SESSION_SECRET=my-secret
export ADMIN_USER=admin ADMIN_PASS=password

# Run
go run .

Adding More Users

Users can be added directly in MariaDB:

INSERT INTO users (username, password_hash, email)
VALUES ('alice', '<bcrypt_hash>', 'alice@example.com');

To generate a bcrypt hash in Go:

hash, _ := bcrypt.GenerateFromPassword([]byte("password"), bcrypt.DefaultCost)
fmt.Println(string(hash))

Stopping and Updating

# Stop
docker compose down

# Stop and remove all data (careful — this deletes posts!)
docker compose down -v

# Rebuild after code changes
docker compose up -d --build

License

CC0 1.0 Universal — This work is dedicated to the public domain.
See https://creativecommons.org/publicdomain/zero/1.0/