Deploying Hugo on Hop3¶
This guide walks you through deploying a Hugo static site on Hop3. Hugo is the world's fastest static site generator, written in Go.
Prerequisites¶
Before you begin, ensure you have:
- A Hop3 server - Follow the Installation Guide
- The Hop3 CLI - Installed on your local machine
- Hugo - Install from gohugo.io
- Git - For version control and deployment
Installing Hugo¶
# macOS (Homebrew)
brew install hugo
# Ubuntu/Debian
sudo apt install hugo
# Or download from GitHub releases:
# https://github.com/gohugoio/hugo/releases
Verify your local setup:
hugo version || (echo "SKIP: Hugo is not installed locally. Install from https://gohugo.io/installation/" && exit 1)
Local Prerequisite
Hugo must be installed on your local machine to build the site before deployment. Unlike frameworks (Rails, Django), Hugo is a standalone binary. Install from gohugo.io before continuing.
Step 1: Create a New Hugo Site¶
Step 2: Add a Theme¶
Download a simple theme:
git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke 2>&1 && echo "Theme added successfully" || echo "Theme already exists"
Configure the theme:
baseURL = 'https://hop3-tuto-hugo.example.com/'
languageCode = 'en-us'
title = 'My Hugo Site'
theme = 'ananke'
[params]
description = "A Hugo site deployed on Hop3"
site_logo = ""
background_color_class = "bg-dark-blue"
Step 3: Create Content¶
Create the home page:
---
title: "Welcome to Hop3!"
description: "Your Hugo site is running"
---
This is a Hugo static site deployed on Hop3.
Built with the world's fastest static site generator.
Create an about page:
Update the about page:
---
title: "About"
date: 2024-01-01
draft: false
---
## About This Site
This Hugo site demonstrates static site deployment on Hop3.
### Features
- **Fast** - Hugo builds in milliseconds
- **Flexible** - Hundreds of themes available
- **Simple** - Markdown content, Git-based workflow
Create a blog post:
---
title: "Hello World"
date: 2024-01-01
draft: false
---
This is the first post on our Hugo site deployed on Hop3!
## Getting Started
Hugo makes it easy to create content:
```bash
hugo new content posts/my-post.md
Then edit the markdown file and rebuild your site.
Step 4: Build and Test¶
Build the site:
Verify the build output:
Test locally:
hugo server &
sleep 3
curl -s http://localhost:1313/ | head -5 || echo "Test completed"
pkill -f "hugo server" 2>/dev/null || true
Step 5: Create Deployment Configuration¶
# Pre-build: Generate static files
prebuild: hugo --minify
# Serve static files
web: npx serve public -l $PORT
[metadata]
id = "hop3-tuto-hugo"
version = "1.0.0"
title = "My Hugo Site"
[build]
before-build = ["hugo --minify"]
packages = ["hugo", "nodejs", "npm"]
[run]
start = "npx serve public -l $PORT"
[port]
web = 3000
[healthcheck]
path = "/"
timeout = 30
interval = 60
Alternatively, use Python's built-in HTTP server (no Node.js required):
[metadata]
id = "hop3-tuto-hugo"
version = "1.0.0"
title = "My Hugo Site"
[build]
before-build = ["hugo --minify"]
packages = ["hugo"]
[run]
start = "python3 -m http.server $PORT --directory public"
[port]
web = 8000
[healthcheck]
path = "/"
Step 6: Initialize Git Repository¶
Update .gitignore:
Deploy to Hop3¶
The following steps require a Hop3 server.
Initialize (First Time Only)¶
Deploy¶
Deploy the application (first deployment creates the app):
Set Hostname¶
Configure the hostname for nginx proxy:
Apply Configuration¶
Redeploy to apply the hostname configuration:
Wait for the application to start:
Verify Deployment¶
View logs:
# View logs
hop3 app:logs hop3-tuto-hugo
# Your app will be available at:
# http://hop3-tuto-hugo.your-hop3-server.example.com
Managing Your Application¶
# Restart the application
hop3 app:restart hop3-tuto-hugo
# View/set environment variables
hop3 config:show hop3-tuto-hugo
hop3 config:set hop3-tuto-hugo NEW_VAR=value
# Scale workers
hop3 ps:scale hop3-tuto-hugo web=2
Advanced Configuration¶
Custom Domain¶
Multiple Environments¶
Multilingual Site¶
# hugo.toml
defaultContentLanguage = 'en'
[languages]
[languages.en]
weight = 1
title = "My Site"
[languages.fr]
weight = 2
title = "Mon Site"
Adding Search (Pagefind)¶
CI/CD with GitHub Actions¶
# .github/workflows/deploy.yml
name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
- name: Build
run: hugo --minify
- name: Deploy
run: hop3 deploy
Troubleshooting¶
Theme Not Found¶
Ensure submodules are initialized:
Build Errors¶
Check Hugo version compatibility:
Missing Content¶
Ensure draft: false in frontmatter for production.
Example hop3.toml¶
[metadata]
id = "hop3-tuto-hugo"
version = "1.0.0"
title = "My Hugo Site"
[build]
before-build = ["hugo --minify"]
packages = ["hugo", "nodejs", "npm"]
[run]
start = "npx serve public -l $PORT -s"
[port]
web = 3000
[healthcheck]
path = "/"