This tracks hugo-based sites, like the blog that are hosted on candaceserver.
Fully containerized and plug-and-playable into any docker compose setup.
For development and testing, you can run everything in containers without needing Hugo installed locally:
# Build the development image
docker build -t blog-dev .
# Run development server with live reloading
docker run -it --rm \
-p 1313:1313 \
-v $(pwd)/bloghome/content:/srv/content \
-v $(pwd)/bloghome/archetypes:/srv/archetypes \
-v $(pwd)/bloghome/assets:/srv/assets \
-v $(pwd)/bloghome/data:/srv/data \
-v $(pwd)/bloghome/i18n:/srv/i18n \
-v $(pwd)/bloghome/layouts:/srv/layouts \
-v $(pwd)/bloghome/static:/srv/static \
-v $(pwd)/bloghome/themes:/srv/themes \
-v $(pwd)/bloghome/hugo.toml:/srv/hugo.toml \
-v $(pwd)/themes:/srv/themes-standalone \
blog-dev hugo server --bind 0.0.0.0 -p 1313 --buildDrafts --buildFuture --disableFastRender
# Build static site for testing
docker run -it --rm \
-v $(pwd)/bloghome:/srv \
-v $(pwd)/themes:/srv/themes-standalone \
blog-dev hugo --destination /srv/public
# Shell access for debugging
docker run -it --rm \
-v $(pwd)/bloghome:/srv \
-v $(pwd)/themes:/srv/themes-standalone \
blog-dev /bin/bash
Create a dev.sh
script for easier development:
#!/bin/bash
docker build -t blog-dev . && \
docker run -it --rm \
-p 1313:1313 \
-v $(pwd)/bloghome/content:/srv/content \
-v $(pwd)/bloghome/archetypes:/srv/archetypes \
-v $(pwd)/bloghome/assets:/srv/assets \
-v $(pwd)/bloghome/data:/srv/data \
-v $(pwd)/bloghome/i18n:/srv/i18n \
-v $(pwd)/bloghome/layouts:/srv/layouts \
-v $(pwd)/bloghome/static:/srv/static \
-v $(pwd)/bloghome/themes:/srv/themes \
-v $(pwd)/bloghome/hugo.toml:/srv/hugo.toml \
-v $(pwd)/themes:/srv/themes-standalone \
blog-dev hugo server --bind 0.0.0.0 -p 1313 --buildDrafts --buildFuture --disableFastRender
Then run: chmod +x dev.sh && ./dev.sh
Visit http://localhost:1313 to see your site. Changes to files will automatically reload the browser.
After completing your development work:
# Build the final static site to verify everything works
docker run -it --rm \
-v $(pwd)/bloghome:/srv \
-v $(pwd)/themes:/srv/themes-standalone \
blog-dev hugo --destination /srv/public
# Check for any Hugo build errors or warnings in the output above
# Verify the build succeeded by checking if files were generated
ls -la bloghome/public/
# Test the production build locally (optional)
docker run -it --rm -p 8080:8080 \
-v $(pwd)/bloghome/public:/usr/share/nginx/html:ro \
nginx:alpine
# Then visit http://localhost:8080 to test the static site
# Check Hugo server logs while development server is running
# (logs appear directly in terminal when running ./dev.sh)
# Debug Hugo configuration issues
docker run -it --rm \
-v $(pwd)/bloghome:/srv \
-v $(pwd)/themes:/srv/themes-standalone \
blog-dev hugo config
# Validate Hugo installation and version
docker run -it --rm blog-dev hugo version
# Check for theme or content issues with verbose output
docker run -it --rm \
-v $(pwd)/bloghome:/srv \
-v $(pwd)/themes:/srv/themes-standalone \
blog-dev hugo --verbose --debug
# Shell access for detailed debugging
docker run -it --rm \
-v $(pwd)/bloghome:/srv \
-v $(pwd)/themes:/srv/themes-standalone \
blog-dev /bin/bash
# Then inside container: hugo --help, ls -la, cat hugo.toml, etc.
# Clean up development image (optional)
docker rmi blog-dev
# Commit your changes
git add .
git commit -m "Update blog content and themes"
git push
The generated static files will be in bloghome/public/
and ready for deployment.
For deployment in the candace-server environment:
cd
to your main docker compose directorygit submodule add https://github.com/candacelabs/blog.git blog
cp blog/docker-compose.blog.example.yaml docker-compose.blog.yaml
docker-compose.blog.yaml
:
docker-compose.yml
:include:
- docker-compose.blog.yaml
docker compose up blog -d
For standalone deployment without docker-compose:
# Build production image
docker build -t blog-prod .
# Run production container
docker run -d \
--name blog \
-p 1313:1313 \
-v $(pwd)/bloghome/content:/srv/content \
-v $(pwd)/bloghome/archetypes:/srv/archetypes \
-v $(pwd)/bloghome/assets:/srv/assets \
-v $(pwd)/bloghome/data:/srv/data \
-v $(pwd)/bloghome/i18n:/srv/i18n \
-v $(pwd)/bloghome/layouts:/srv/layouts \
-v $(pwd)/bloghome/static:/srv/static \
-v $(pwd)/bloghome/themes:/srv/themes \
-v $(pwd)/bloghome/hugo.toml:/srv/hugo.toml \
--restart unless-stopped \
blog-prod
# Check deployment status
docker logs blog
# Stop/start as needed
docker stop blog
docker start blog
To deploy as static files (nginx, Apache, etc.):
# Generate static files
docker run -it --rm \
-v $(pwd)/bloghome:/srv \
-v $(pwd)/themes:/srv/themes-standalone \
blog-dev hugo --destination /srv/public
# Copy static files to web server
rsync -av bloghome/public/ user@server:/var/www/html/
# or
scp -r bloghome/public/* user@server:/var/www/html/
To showcase your theme/template on GitHub Pages for sharing:
.github/workflows/hugo.yml
:name: Deploy Hugo site to GitHub Pages
on:
push:
branches: ["main"]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.148.0'
extended: true
- name: Build with Hugo
working-directory: ./bloghome
run: hugo --minify --baseURL "https://$.github.io/$/"
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./bloghome/public
deploy:
environment:
name: github-pages
url: $
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
bloghome/hugo.toml
to include:# Add this line for GitHub Pages deployment
baseURL = "https://yourusername.github.io/blog"
# Generate static files with correct baseURL
docker run -it --rm \
-v $(pwd)/bloghome:/srv \
-v $(pwd)/themes:/srv/themes-standalone \
blog-dev hugo --destination /srv/public --baseURL "https://yourusername.github.io/blog"
# Create gh-pages branch and deploy
git checkout --orphan gh-pages
git rm -rf .
cp -r bloghome/public/* .
git add .
git commit -m "Deploy to GitHub Pages"
git push origin gh-pages
git checkout main
After GitHub Pages is set up, create a demo repository:
bloghome/content/
Example repository description:
🎨 Hugo Blog Theme - Clean, minimal theme for technical blogs
📖 Live Demo: https://yourusername.github.io/blog
Your template will be live at https://yourusername.github.io/blog
for others to preview before using it.