hugo is a free and open-source static site generator. Hugo provides fast static site generator with flexible themes
1. Prerequisites
2. Supported Operating Systems
This guide supports installation on:
3. Installation
RHEL/CentOS/Rocky Linux/AlmaLinux
# Install EPEL repository if needed
sudo dnf install -y epel-release
# Install hugo
sudo dnf install -y hugo
# Enable and start service
sudo systemctl enable --now hugo
# Configure firewall
sudo firewall-cmd --permanent --add-port=N/A/tcp
sudo firewall-cmd --reload
# Verify installation
hugo --version
Debian/Ubuntu
# Update package index
sudo apt update
# Install hugo
sudo apt install -y hugo
# Enable and start service
sudo systemctl enable --now hugo
# Configure firewall
sudo ufw allow N/A
# Verify installation
hugo --version
Arch Linux
# Install hugo
sudo pacman -S hugo
# Enable and start service
sudo systemctl enable --now hugo
# Verify installation
hugo --version
Alpine Linux
# Install hugo
apk add --no-cache hugo
# Enable and start service
rc-update add hugo default
rc-service hugo start
# Verify installation
hugo --version
openSUSE/SLES
# Install hugo
sudo zypper install -y hugo
# Enable and start service
sudo systemctl enable --now hugo
# Configure firewall
sudo firewall-cmd --permanent --add-port=N/A/tcp
sudo firewall-cmd --reload
# Verify installation
hugo --version
macOS
# Using Homebrew
brew install hugo
# Start service
brew services start hugo
# Verify installation
hugo --version
FreeBSD
# Using pkg
pkg install hugo
# Enable in rc.conf
echo 'hugo_enable="YES"' >> /etc/rc.conf
# Start service
service hugo start
# Verify installation
hugo --version
Windows
# Using Chocolatey
choco install hugo
# Or using Scoop
scoop install hugo
# Verify installation
hugo --version
Initial Configuration
Basic Configuration
# Create configuration directory
sudo mkdir -p /etc/hugo
# Set up basic configuration
# See official documentation for detailed configuration options
# Test configuration
hugo --version
5. Service Management
systemd (RHEL, Debian, Ubuntu, Arch, openSUSE)
# Enable service
sudo systemctl enable hugo
# Start service
sudo systemctl start hugo
# Stop service
sudo systemctl stop hugo
# Restart service
sudo systemctl restart hugo
# Check status
sudo systemctl status hugo
# View logs
sudo journalctl -u hugo -f
OpenRC (Alpine Linux)
# Enable service
rc-update add hugo default
# Start service
rc-service hugo start
# Stop service
rc-service hugo stop
# Restart service
rc-service hugo restart
# Check status
rc-service hugo status
rc.d (FreeBSD)
# Enable in /etc/rc.conf
echo 'hugo_enable="YES"' >> /etc/rc.conf
# Start service
service hugo start
# Stop service
service hugo stop
# Restart service
service hugo restart
# Check status
service hugo status
launchd (macOS)
# Using Homebrew services
brew services start hugo
brew services stop hugo
brew services restart hugo
# Check status
brew services list | grep hugo
Windows Service Manager
# Start service
net start hugo
# Stop service
net stop hugo
# Using PowerShell
Start-Service hugo
Stop-Service hugo
Restart-Service hugo
# Check status
Get-Service hugo
Advanced Configuration
See the official documentation for advanced configuration options.
Reverse Proxy Setup
nginx Configuration
upstream hugo_backend {
server 127.0.0.1:N/A;
}
server {
listen 80;
server_name hugo.example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name hugo.example.com;
ssl_certificate /etc/ssl/certs/hugo.example.com.crt;
ssl_certificate_key /etc/ssl/private/hugo.example.com.key;
location / {
proxy_pass http://hugo_backend;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Apache Configuration
<VirtualHost *:80>
ServerName hugo.example.com
Redirect permanent / https://hugo.example.com/
</VirtualHost>
<VirtualHost *:443>
ServerName hugo.example.com
SSLEngine on
SSLCertificateFile /etc/ssl/certs/hugo.example.com.crt
SSLCertificateKeyFile /etc/ssl/private/hugo.example.com.key
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:N/A/
ProxyPassReverse / http://127.0.0.1:N/A/
</VirtualHost>
HAProxy Configuration
frontend hugo_frontend
bind *:80
bind *:443 ssl crt /etc/ssl/certs/hugo.pem
redirect scheme https if !{ ssl_fc }
default_backend hugo_backend
backend hugo_backend
balance roundrobin
server hugo1 127.0.0.1:N/A check
Security Configuration
Basic Security Setup
# Set appropriate permissions
sudo chown -R hugo:hugo /etc/hugo
sudo chmod 750 /etc/hugo
# Configure firewall
sudo firewall-cmd --permanent --add-port=N/A/tcp
sudo firewall-cmd --reload
# Enable SELinux policies (if applicable)
sudo setsebool -P httpd_can_network_connect on
Database Setup
See official documentation for database configuration requirements.
Performance Optimization
System Tuning
# Basic system tuning
echo 'net.core.somaxconn = 65535' | sudo tee -a /etc/sysctl.conf
echo 'net.ipv4.tcp_max_syn_backlog = 65535' | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
Monitoring
Basic Monitoring
# Check service status
sudo systemctl status hugo
# View logs
sudo journalctl -u hugo -f
# Monitor resource usage
top -p $(pgrep hugo)
9. Backup and Restore
Backup Script
#!/bin/bash
# Basic backup script
BACKUP_DIR="/backup/hugo"
DATE=$(date +%Y%m%d_%H%M%S)
mkdir -p "$BACKUP_DIR"
tar -czf "$BACKUP_DIR/hugo-backup-$DATE.tar.gz" /etc/hugo /var/lib/hugo
echo "Backup completed: $BACKUP_DIR/hugo-backup-$DATE.tar.gz"
Restore Procedure
# Stop service
sudo systemctl stop hugo
# Restore from backup
tar -xzf /backup/hugo/hugo-backup-*.tar.gz -C /
# Start service
sudo systemctl start hugo
6. Troubleshooting
Common Issues
1. Service won't start:
# Check logs
sudo journalctl -u hugo -n 100
sudo tail -f /var/log/hugo/hugo.log
# Check configuration
hugo --version
# Check permissions
ls -la /etc/hugo
2. Connection issues:
# Check if service is listening
sudo ss -tlnp | grep N/A
# Test connectivity
telnet localhost N/A
# Check firewall
sudo firewall-cmd --list-all
3. Performance issues:
# Check resource usage
top -p $(pgrep hugo)
# Check disk I/O
iotop -p $(pgrep hugo)
# Check connections
ss -an | grep N/A
Integration Examples
Docker Compose Example
version: '3.8'
services:
hugo:
image: hugo:latest
ports:
- "N/A:N/A"
volumes:
- ./config:/etc/hugo
- ./data:/var/lib/hugo
restart: unless-stopped
Maintenance
Update Procedures
# RHEL/CentOS/Rocky/AlmaLinux
sudo dnf update hugo
# Debian/Ubuntu
sudo apt update && sudo apt upgrade hugo
# Arch Linux
sudo pacman -Syu hugo
# Alpine Linux
apk update && apk upgrade hugo
# openSUSE
sudo zypper update hugo
# FreeBSD
pkg update && pkg upgrade hugo
# Always backup before updates
tar -czf /backup/hugo-pre-update-$(date +%Y%m%d).tar.gz /etc/hugo
# Restart after updates
sudo systemctl restart hugo
Regular Maintenance
# Log rotation
sudo logrotate -f /etc/logrotate.d/hugo
# Clean old logs
find /var/log/hugo -name "*.log" -mtime +30 -delete
# Check disk usage
du -sh /var/lib/hugo
Additional Resources
---
Note: This guide is part of the HowToMgr collection. Always refer to official documentation for the most up-to-date information.