fixed post links
This commit is contained in:
183
DEPLOYMENT.md
183
DEPLOYMENT.md
@@ -1,6 +1,6 @@
|
|||||||
# Deployment Guide for LXC Container
|
# Deployment Guide for LXC Container
|
||||||
|
|
||||||
This guide explains how to deploy this Hugo website to an LXC container running Arch Linux (or similar). The site is built as a static site and served via nginx.
|
This guide explains how to deploy this Hugo website to an LXC container running Ubuntu (or similar). The site runs as a live Hugo server with a reverse proxy forwarding requests.
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
@@ -80,117 +80,23 @@ cd dustin.coffee
|
|||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
```
|
```
|
||||||
|
|
||||||
## Step 3: Build Static Site
|
## Step 3: Run Hugo Server (Reverse Proxy Setup)
|
||||||
|
|
||||||
Generate the static site:
|
Since you're using a reverse proxy pointing to the LXC container, run Hugo as a live server:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
hugo --minify
|
|
||||||
```
|
|
||||||
|
|
||||||
The built site will be in the `public/` directory.
|
|
||||||
|
|
||||||
## Step 4: Install and Configure nginx
|
|
||||||
|
|
||||||
Install nginx:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo pacman -S nginx
|
|
||||||
```
|
|
||||||
|
|
||||||
Create nginx configuration file at `/etc/nginx/sites-available/dustin.coffee` (create directory if needed):
|
|
||||||
|
|
||||||
```nginx
|
|
||||||
server {
|
|
||||||
listen 80;
|
|
||||||
listen [::]:80;
|
|
||||||
server_name dustin.coffee www.dustin.coffee;
|
|
||||||
|
|
||||||
root /srv/www/dustin.coffee/public;
|
|
||||||
index index.html;
|
|
||||||
|
|
||||||
# Security headers
|
|
||||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
||||||
add_header X-Content-Type-Options "nosniff" always;
|
|
||||||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
|
||||||
|
|
||||||
# Gzip compression
|
|
||||||
gzip on;
|
|
||||||
gzip_vary on;
|
|
||||||
gzip_min_length 1024;
|
|
||||||
gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml+rss application/json;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
try_files $uri $uri/ =404;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Cache static assets
|
|
||||||
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
|
|
||||||
expires 365d;
|
|
||||||
add_header Cache-Control "public, immutable";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Enable the site by creating a symlink:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo ln -s /etc/nginx/sites-available/dustin.coffee /etc/nginx/sites-enabled/
|
|
||||||
sudo nginx -t # Test configuration
|
|
||||||
sudo systemctl restart nginx
|
|
||||||
```
|
|
||||||
|
|
||||||
## Step 5: Set Up SSL with Let's Encrypt (Optional but Recommended)
|
|
||||||
|
|
||||||
Install certbot:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo pacman -S certbot certbot-nginx
|
|
||||||
```
|
|
||||||
|
|
||||||
Obtain certificate:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo certbot --nginx -d dustin.coffee -d www.dustin.coffee
|
|
||||||
```
|
|
||||||
|
|
||||||
Certbot will automatically update nginx configuration.
|
|
||||||
|
|
||||||
## Step 6: Automation Script
|
|
||||||
|
|
||||||
Create a deployment script `deploy.sh` in the repository root:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
#!/bin/bash
|
|
||||||
# deploy.sh - rebuild and copy site
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
cd /srv/www/dustin.coffee
|
cd /srv/www/dustin.coffee
|
||||||
|
hugo server --bind 0.0.0.0 --port 1313 --baseURL=https://dustin.coffee --appendPort=false --disableLiveReload
|
||||||
# Pull latest changes
|
|
||||||
git pull
|
|
||||||
|
|
||||||
# Build site
|
|
||||||
hugo --minify
|
|
||||||
|
|
||||||
# Optional: restart nginx if configuration changed
|
|
||||||
# sudo systemctl reload nginx
|
|
||||||
|
|
||||||
echo "Deployment completed at $(date)"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Make it executable:
|
**Important flags:**
|
||||||
|
- `--bind 0.0.0.0` – Listen on all network interfaces
|
||||||
|
- `--port 1313` – Port for the reverse proxy to forward to (adjust if different)
|
||||||
|
- `--baseURL=https://dustin.coffee` – Your public domain (must match reverse proxy)
|
||||||
|
- `--appendPort=false` – Don't include port 1313 in generated URLs (critical for correct links)
|
||||||
|
- `--disableLiveReload` – Disable live reload in production
|
||||||
|
|
||||||
```bash
|
### Systemd Service (Recommended for production)
|
||||||
chmod +x deploy.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
Now after SSH-ing into the container, you can run `./deploy.sh` to update the site.
|
|
||||||
|
|
||||||
## Step 7: Systemd Service (Alternative: Hugo Server)
|
|
||||||
|
|
||||||
If you prefer to run Hugo as a server (not recommended for production), create a systemd service:
|
|
||||||
|
|
||||||
Create `/etc/systemd/system/hugo-dustin.service`:
|
Create `/etc/systemd/system/hugo-dustin.service`:
|
||||||
|
|
||||||
@@ -204,14 +110,19 @@ Type=simple
|
|||||||
User=www-data
|
User=www-data
|
||||||
Group=www-data
|
Group=www-data
|
||||||
WorkingDirectory=/srv/www/dustin.coffee
|
WorkingDirectory=/srv/www/dustin.coffee
|
||||||
ExecStart=/usr/bin/hugo server --bind 0.0.0.0 --port 1313 --baseURL=https://dustin.coffee/
|
ExecStart=/usr/bin/hugo server --bind 0.0.0.0 --port 1313 --baseURL=https://dustin.coffee --appendPort=false --disableLiveReload
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
```
|
```
|
||||||
|
|
||||||
Then enable and start:
|
**Adjust paths:**
|
||||||
|
- Replace `/usr/bin/hugo` with `hugo` if installed via apt repository
|
||||||
|
- Set `User`/`Group` to your LXC user if not www-data
|
||||||
|
- Update `WorkingDirectory` to your site path
|
||||||
|
|
||||||
|
Enable and start the service:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
@@ -219,19 +130,66 @@ sudo systemctl enable hugo-dustin
|
|||||||
sudo systemctl start hugo-dustin
|
sudo systemctl start hugo-dustin
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Check status: `sudo systemctl status hugo-dustin`
|
||||||
|
|
||||||
|
## Step 4: Reverse Proxy Configuration
|
||||||
|
|
||||||
|
SSL/TLS encryption should be configured at your reverse proxy level (not Hugo).
|
||||||
|
|
||||||
|
Hugo itself runs on HTTP (port 1313). Your reverse proxy should:
|
||||||
|
- Terminate SSL at the proxy (HTTPS on port 443)
|
||||||
|
- Forward HTTP requests to Hugo on port 1313
|
||||||
|
- Set appropriate `X-Forwarded-*` headers if needed
|
||||||
|
|
||||||
|
**If using Caddy, Traefik, or another reverse proxy:** Consult your proxy's documentation for SSL configuration. Most modern proxies automatically handle SSL with Let's Encrypt.
|
||||||
|
|
||||||
|
**Important:** Ensure your reverse proxy forwards requests to `http://<lxc-internal-ip>:1313` (or `localhost:1313` if proxy runs on same container). The domain `dustin.coffee` must resolve to your reverse proxy's public IP.
|
||||||
|
|
||||||
|
## Step 5: Automation Script
|
||||||
|
|
||||||
|
Create a deployment script `deploy.sh` in the repository root:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
#!/bin/bash
|
||||||
|
# deploy.sh - update site and restart Hugo server
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
cd /srv/www/dustin.coffee
|
||||||
|
|
||||||
|
echo "Pulling latest changes from git..."
|
||||||
|
git pull
|
||||||
|
|
||||||
|
echo "Updating theme submodule..."
|
||||||
|
git submodule update --init --recursive
|
||||||
|
|
||||||
|
echo "Restarting Hugo server..."
|
||||||
|
sudo systemctl restart hugo-dustin
|
||||||
|
|
||||||
|
echo "Deployment completed at $(date)"
|
||||||
|
```
|
||||||
|
|
||||||
|
Make it executable:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
chmod +x deploy.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Now after SSH-ing into the container, you can run `./deploy.sh` to update the site.
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
- Update the `baseURL` in `hugo.toml` if your domain changes.
|
- Update the `baseURL` in `hugo.toml` if your domain changes.
|
||||||
- The site uses a custom theme `personal`; ensure all theme files are committed to git.
|
- The site uses the `hello-friend-ng` theme as a git submodule.
|
||||||
- Blog posts are stored in `content/posts/` as markdown files.
|
- Blog posts are stored in `content/posts/` as markdown files.
|
||||||
- To add new blog posts, create markdown files in `content/posts/` on your development machine, push to git, then run the deploy script on the container.
|
- To add new blog posts, create markdown files in `content/posts/` on your development machine, push to git, then run the deploy script on the container.
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
- If nginx shows 404, ensure the `public/` directory exists and contains built files.
|
- If Hugo server fails to start, check logs: `sudo journalctl -u hugo-dustin -f`
|
||||||
- If Hugo fails to build, check Hugo version matches the one used in development.
|
- If Hugo fails to build, check Hugo version matches the one used in development.
|
||||||
- Check nginx error logs: `sudo journalctl -u nginx`
|
- If blog post URLs are incorrect, verify `permalinks` configuration in `hugo.toml`.
|
||||||
- Check Hugo build logs: run `hugo --verbose`
|
- If reverse proxy shows 404, ensure Hugo server is running on port 1313 and reverse proxy forwards to correct port.
|
||||||
|
|
||||||
## Updating
|
## Updating
|
||||||
|
|
||||||
@@ -240,5 +198,4 @@ To update the site after making changes on your development machine:
|
|||||||
1. Push changes to your git server
|
1. Push changes to your git server
|
||||||
2. SSH into LXC container
|
2. SSH into LXC container
|
||||||
3. Navigate to site directory: `cd /srv/www/dustin.coffee`
|
3. Navigate to site directory: `cd /srv/www/dustin.coffee`
|
||||||
4. Run `git pull` then `./deploy.sh` (or just `hugo --minify`)
|
4. Run `./deploy.sh`
|
||||||
|
|
||||||
17
deploy.sh
17
deploy.sh
@@ -1,6 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Deployment script for Hugo site on LXC container
|
# Deployment script for Hugo site on LXC container
|
||||||
# Run this script after SSH-ing into the container and navigating to the site directory
|
# Run this script after SSH-ing into the container and navigating to the site directory
|
||||||
|
# This script updates the site and restarts the Hugo server systemd service
|
||||||
|
|
||||||
set -e # Exit on error
|
set -e # Exit on error
|
||||||
|
|
||||||
@@ -10,13 +11,13 @@ echo "Starting deployment at $(date)"
|
|||||||
echo "Pulling latest changes from git..."
|
echo "Pulling latest changes from git..."
|
||||||
git pull
|
git pull
|
||||||
|
|
||||||
# Build the site with minification
|
# Update theme submodule (required for hello-friend-ng theme)
|
||||||
echo "Building site with Hugo..."
|
echo "Updating theme submodule..."
|
||||||
hugo --minify
|
git submodule update --init --recursive
|
||||||
|
|
||||||
|
# Restart Hugo server to pick up changes
|
||||||
|
echo "Restarting Hugo server..."
|
||||||
|
sudo systemctl restart hugo-dustin
|
||||||
|
|
||||||
echo "Deployment completed successfully at $(date)"
|
echo "Deployment completed successfully at $(date)"
|
||||||
echo "Site updated in ./public directory"
|
echo "Hugo server restarted and changes are live."
|
||||||
|
|
||||||
# Optional: Reload nginx if configuration changed
|
|
||||||
# echo "Reloading nginx..."
|
|
||||||
# sudo systemctl reload nginx
|
|
||||||
29
hugo.toml
29
hugo.toml
@@ -33,6 +33,35 @@ theme = 'hello-friend-ng'
|
|||||||
images = [""]
|
images = [""]
|
||||||
themeColor = "#2d3748"
|
themeColor = "#2d3748"
|
||||||
|
|
||||||
|
# Favicon colors
|
||||||
|
[params.favicon.color]
|
||||||
|
mask = "#2d3748"
|
||||||
|
msapplication = "#2d3748"
|
||||||
|
theme = "#2d3748"
|
||||||
|
|
||||||
|
# Footer configuration
|
||||||
|
[params.footer]
|
||||||
|
trademark = 2026
|
||||||
|
rss = true
|
||||||
|
copyright = true
|
||||||
|
author = true
|
||||||
|
topText = []
|
||||||
|
bottomText = [
|
||||||
|
"Powered by <a href=\"https://gohugo.io\">Hugo</a>",
|
||||||
|
"Theme: <a href=\"https://github.com/rhazdon/hugo-theme-hello-friend-ng\">hello-friend-ng</a>"
|
||||||
|
]
|
||||||
|
|
||||||
|
# Reading time
|
||||||
|
enableReadingTime = true
|
||||||
|
|
||||||
|
# Theme toggle (default respects OS preference)
|
||||||
|
enableThemeToggle = false
|
||||||
|
|
||||||
|
# Social icons (uncomment and add as needed)
|
||||||
|
# [[params.social]]
|
||||||
|
# name = "github"
|
||||||
|
# url = "https://github.com/yourusername"
|
||||||
|
|
||||||
[taxonomies]
|
[taxonomies]
|
||||||
tag = "tags"
|
tag = "tags"
|
||||||
category = "categories"
|
category = "categories"
|
||||||
|
|||||||
Reference in New Issue
Block a user