go-blog is a standalone executable that hosts a customizable blog! Configure some settings, and run the binary, and you will have a blog which people can visit!
- You will need at least
go
1.20. This is the version I was able to test it. - Access to a MySQL database (connection string)
To build the program, you can just run the included shell script, build.sh
.
./build.sh
After that, the server
executable will be emitted. This is the binary to run the service.
Ensure that the configuration.json
has the correct settings, and just run the server like this:
./server
The blog is live! 🎉🥳
The blog is designed to highly customizable. If you want to change the static content to fit your tastes, here are some good places to start:
- All static files are within the
public
directory. The common use case is to place static assets such as JavaScript, and CSS here. - All template files are in the
views
directory. Modify these to customize your pages.
You'd minimally need a post
table with the following MySQL schema:
CREATE TABLE post (
id PRIMARY KEY AUTO_INCREMENT,
slug TEXT,
title TEXT,
content TEXT,
created DATETIME,
published BOOLEAN
);
It's relatively straightforward to configure the configuration.json
file. The 2 main things to make the app work are:
database_url_env
- The environment variable to reference so that the connection string to the database. So for example, common setting value would beDATABASE_URL
, which would reference theenv
variable calledDATABASE_URL
within the system to find the DB connection string.http_port
= The port to listen to.
The connection string is in the format:
username:password@tcp(hostname:port)/database_name
So you'd have an environment variable like this:
export DATABASE_URL="username:password@tcp(hostname:port)/database_name"
And in configuration.json
, you can set it like this:
{
"database_url_env": "DATABASE_URL"
}
This project will be updated from time to time. I use it for real things. You can contact me at [email protected] too!