Change mirror command to work better with existing target directories: - Use cd/lcd to change to directories first - Simplify mirror command to work from current directories - Add mkdir fallback if target directory doesn't exist - Fix SSL setting from ssl-allow to ssl-force for proper FTPS This resolves issues when httpsdocs directory already exists on server. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
4.2 KiB
Deployment Guide
This guide explains how to deploy the Hugo-built static site to the production server at www.markusgraf.ch.
Prerequisites
Before deploying, ensure you have:
- Built the site: Run
hugo buildto generate thepublic/directory - lftp installed: The deployment script requires the
lftpcommand-line tool - FTPS credentials: You need the FTPS username and password for the server
Installing lftp
If lftp is not installed on your system:
# Ubuntu/Debian
sudo apt-get install lftp
# macOS
brew install lftp
# Fedora
sudo dnf install lftp
Deployment Process
1. Build the Site
First, build the Hugo site:
hugo build
This generates the static files in the public/ directory.
2. Set Environment Variables
Set the FTPS credentials as environment variables:
export FTPS_USER='gurix'
export FTPS_PASSWORD='your-password-here'
Important: Never commit passwords to version control. Credentials should only be stored as environment variables.
3. Run the Deployment Script
Execute the deployment script:
./scripts/deploy.sh
The script will:
- Check that all prerequisites are met
- Connect to www.markusgraf.ch via FTPS
- Upload all files from
public/tohttpsdocs/on the server - Display progress and completion status
Complete Example
Here's the full workflow:
# Build the site
hugo build
# Set credentials (only needed once per session)
export FTPS_USER='gurix'
export FTPS_PASSWORD='your-password'
# Deploy
./scripts/deploy.sh
Server Configuration
The deployment script uses the following configuration:
- Server: www.markusgraf.ch
- Protocol: FTPS (FTP over SSL/TLS)
- Username: gurix
- Target Directory: httpsdocs/
- Source Directory: public/
Security Notes
Credential Management
- Never hardcode passwords in scripts or configuration files
- Never commit passwords to version control
- Use environment variables to pass credentials securely
- The deployment script never displays passwords in its output
Optional: Using .env Files
For convenience, you can create a .env file (which is ignored by git):
# .env
FTPS_PASSWORD=your-password
Then source it before deployment:
source .env
./scripts/deploy.sh
Troubleshooting
Error: "Directory 'public' does not exist"
Cause: The Hugo site hasn't been built yet.
Solution: Run hugo build before deploying.
Error: "lftp is not installed"
Cause: The lftp tool is not available on your system.
Solution: Install lftp using the instructions above.
Error: "FTPS_PASSWORD environment variable is not set"
Cause: The password environment variable hasn't been set.
Solution: Run export FTPS_PASSWORD='your-password' before deploying.
Connection Failures
Cause: Network issues or incorrect credentials.
Solutions:
- Verify your internet connection
- Check that the password is correct
- Ensure the server (www.markusgraf.ch) is accessible
- Verify firewall settings aren't blocking FTPS (port 21)
Partial Upload Failures
Cause: Network interruption during upload.
Solution: Simply run the deployment script again. The mirror command will resume and complete the upload.
Advanced Usage
Testing Without Deploying
To test the script without actually uploading files, you can modify the deploy() function temporarily to use the --dry-run flag:
mirror --reverse --delete --verbose --parallel=3 --dry-run $SOURCE_DIR $TARGET_DIR;
Deployment from CI/CD
For automated deployments from CI/CD pipelines:
- Store
FTPS_PASSWORDas a secret in your CI/CD system - Ensure the CI/CD environment has
lftpinstalled - Run the deployment script after successful builds
Example GitHub Actions workflow snippet:
- name: Deploy to server
env:
FTPS_PASSWORD: ${{ secrets.FTPS_PASSWORD }}
run: ./scripts/deploy.sh
Support
If you encounter issues not covered in this guide:
- Check the server logs
- Verify network connectivity to www.markusgraf.ch
- Ensure the
httpsdocs/directory exists on the server - Contact your hosting provider for server-side issues