π Hugo Source Backup #
This guide outlines how to back up your Hugo source files (excluding the public/
folder) to a private GitHub repository.
π Folder Structure #
Typical Hugo project structure:
hugo-site/
βββ archetypes/
βββ content/
βββ layouts/
βββ static/
βββ themes/
βββ config.toml
βββ public/ # <- This is ignored for source backup
βββ backup.sh # Backup script
β 1. Create a Private GitHub Repo #
- Go to https://github.com/new
- Name it something like
hugo-source
- Set visibility to Private
- Donβt initialize with README or license
β 2. Initialize Git in Your Hugo Site (if not already) #
git init
git remote add origin https://github.com/<your-username>/hugo-source.git
echo "public/" >> .gitignore
β 3. Create the Backup Script #
Create a file named backup.sh
in the root of your Hugo project:
#!/bin/bash
git add .
git commit -m "π Backup: $(date +'%Y-%m-%d %H:%M:%S')"
git push origin main
echo "β
Backup Complete!"
Make it executable:
chmod +x backup.sh
β 4. Use It! #
To back up your source files:
./backup.sh
π Notes #
- Only your source files are backed up.
- The
public/
folder is excluded (itβs where the generated site lives). - Combine with
deploy.sh
for full workflow automation.