A modern, static site generator for personal blogs built with Go. Features a clean admin interface for content management, automatic static site generation, and easy deployment.
- π Content Management: Create and manage blog posts, portfolio items, and static pages
- π¨ Modern Admin UI: Clean, responsive interface built with Tailwind CSS
- β‘ Static Site Generation: Fast, SEO-friendly static HTML output
- π Easy Deployment: Simple deployment with nginx and systemd
-
Prerequisites
- Go 1.22 or later
- Node.js 16+ (for Tailwind CSS)
- SQLite3
-
Installation
# Clone the repository git clone <repository-url> cd personal-blog-generator # Install Go dependencies go mod tidy # Install Node.js dependencies npm install
-
Environment Setup
# Create configuration directory mkdir -p ~/.personal-blog-generator # Create .env file with your settings cat > ~/.personal-blog-generator/.env << EOF # Database configuration DB_PATH=~/.personal-blog/-generatorblog.db # Server configuration APP_PORT=8080 EOF # Edit .env if needed nano ~/.personal-blog-generator/.env
-
Run Locally
# Build Tailwind CSS (in background) npx tailwindcss -i ./admin-files/input.css -o ./admin-files/css/style.css --watch & # Run the application go run main.go
-
Access the Application
| Variable | Description | Default |
|---|---|---|
DB_PATH |
Path to SQLite database | blog.db |
APP_PORT |
Port for the application | 8080 |
TEMPLATE_PATH |
Path to HTML templates directory | ./templates |
OUTPUT_PATH |
Path to generated static site directory | ./html-outputs |
ADMIN_USERNAME |
Username for admin dashboard | admin |
ADMIN_PASSWORD |
Password for admin dashboard | admin |
DEPLOY_HOST |
SSH host for deployment | - |
DEPLOY_USER |
SSH user for deployment | - |
DEPLOY_PATH |
Remote path for deployment | - |
BACKUP_PATH |
Path for database backups | - |
Deployment is still an idea for the future. This configuration is unused at the moment.
Access the admin at /admin/dashboard with basic authentication.
- Posts: Create, edit, and manage blog posts with markdown support
- Portfolio: Showcase your projects and work
- Pages: Create static pages for your site
- Publishing: Generate and deploy your static site
- Backup: Automatic database backups
- Rich text editing with markdown support
- Tag management for posts
- Image upload and management
- SEO-friendly URLs and metadata
Deployment is still an idea for the future.
-
Configure Environment
# Update ~/.personal-blog-generator/.env with deployment settings cat >> ~/.personal-blog-generator/.env << EOF DEPLOY_HOST=your-server.com DEPLOY_USER=your-user DEPLOY_PATH=/var/www/blog BACKUP_PATH=./backups EOF
-
Deploy
./deploy.sh
# Create user and directories
sudo useradd -m -s /bin/bash blog
sudo mkdir -p /var/www/blog
sudo chown -R blog:blog /var/www/blog
# Install dependencies
sudo apt update
sudo apt install nginx sqlite3 certbot python3-certbot-nginx# Copy files to server
scp main blog.db .env blog@your-server.com:/var/www/blog/
# Set permissions
sudo chown -R blog:blog /var/www/blog
sudo chmod 600 /var/www/blog/.env# Copy nginx config
sudo cp nginx.conf /etc/nginx/sites-available/blog
sudo ln -s /etc/nginx/sites-available/blog /etc/nginx/sites-enabled/
# Update server_name and root path in nginx.conf
sudo nano /etc/nginx/sites-available/blog
# Test configuration
sudo nginx -t
# Reload nginx
sudo systemctl reload nginxsudo certbot --nginx -d your-domain.com -d www.your-domain.com# Copy service file
sudo cp personal-blog-generator.service /etc/systemd/system/
# Reload systemd
sudo systemctl daemon-reload
# Enable and start service
sudo systemctl enable personal-blog-generator
sudo systemctl start personal-blog-generator
# Check status
sudo systemctl status personal-blog-generator# View logs
sudo journalctl -u personal-blog-generator -f
# Restart service
sudo systemctl restart personal-blog-generator
# Stop service
sudo systemctl stop personal-blog-generatorpersonal-blog-generator/
βββ admin-files/ # Admin interface static files
βββ html-outputs/ # Generated static site
βββ internal/ # Go application code
β βββ db/ # Database utilities
β βββ generator/ # Static site generator
β βββ handlers/ # HTTP handlers
β βββ models/ # Data models
β βββ repository/ # Data access layer
βββ static/ # Public static assets
βββ templates/ # HTML templates
βββ main.go # Application entry point
βββ nginx.conf # Production nginx config
βββ nginx-dev.conf # Development nginx config
βββ personal-blog-generator.service # Systemd service file
βββ README.md # This file
# Build the application
go build -o main .
# Build for production
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o main .# Run all tests
go test ./...
# Run with coverage
go test -cover ./...# Format code
go fmt ./...
# Vet code
go vet ./...-
Port already in use
# Find process using port 8080 sudo lsof -i :8080 # Kill the process sudo kill -9 <PID>
-
Database connection failed
- Check
DB_PATHin.env - Ensure database file exists and has correct permissions
- Run database migrations if needed
- Check
-
Admin login not working
- Check
.htpasswdfile exists and has correct format - Verify nginx configuration includes auth directives
- Check
-
Static site not generating
- Check file permissions on
html-outputs/directory - Ensure all required templates exist
- Check application logs for errors
- Check file permissions on
-
Service not starting
# Check service status sudo systemctl status personal-blog-generator # View logs sudo journalctl -u personal-blog-generator -f
- Application logs: Check systemd journal
- Nginx logs:
/var/log/nginx/ - Database logs: Check SQLite file permissions
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Create an issue on GitHub
- Check the troubleshooting section
- Review the documentation