Versioning & Deployment
warning
Never deploy by editing files live in production. Deploy from a versioned artifact or a repo so you can roll back quickly.
Prerequisites
| Concept | What it means | Example |
|---|---|---|
| Git repo | Version history for theme code | git init |
| Tags/releases | Named snapshots | v1.2.0 |
| Artifact | Deployable package | generatepress-child.tgz |
| Rollback | Restore previous version | re-deploy older tag |
Safety Notes
- Child themes are production code.
- Versioning prevents "mystery changes".
- Deployment without rollback is downtime waiting to happen.
How It Works
You commit changes, tag a release, build/package artifacts, and deploy those artifacts to servers.
Step-by-Step Deployment Workflow
Step 1: Initialize a Git Repo
init-child-theme-git.sh
cd /var/www/html/wp-content/themes/generatepress-child
git init
git add .
git commit -m "Initialize child theme"
Step 2: Add a .gitignore
wp-content/themes/generatepress-child/.gitignore
node_modules/
vendor/
.DS_Store
Step 3: Tag a Release
tag-release.sh
cd /var/www/html/wp-content/themes/generatepress-child
git tag v0.1.0
git tag
Step 4: Package an Artifact
package-release.sh
cd /var/www/html
tar -czf /tmp/generatepress-child-v0.1.0.tgz -C wp-content/themes generatepress-child
ls -lh /tmp/generatepress-child-v0.1.0.tgz
Step 5: Capture a Deploy Fingerprint
capture-deploy-fingerprint.sh
cd /var/www/html/wp-content/themes/generatepress-child
git rev-parse HEAD
git log -1 --oneline
Optional Configuration
Example 1: Deploy by Copying the Theme Folder
Use your preferred deploy tool (rsync/scp/CI) to upload the folder or the artifact.
Example 2: Roll Back
Rollback strategy:
- Re-deploy previous artifact
- Purge cache
- Confirm logged-out behavior
Example 3: Build an Artifact from a Tag (Alternative)
git-archive-artifact.sh
cd /var/www/html/wp-content/themes/generatepress-child
git archive --format=tar.gz -o /tmp/generatepress-child-$(git describe --tags --always).tgz HEAD
ls -lh /tmp/generatepress-child-*.tgz | tail -n 1
Example 4: Deployment Matrix
| Method | Pros | Cons |
|---|---|---|
| Copy folder (rsync/scp) | simple | easy to drift |
| Deploy artifact | reproducible | needs packaging |
| CI pipeline | repeatable | setup cost |
Best Practices
| Practice | Why |
|---|---|
| Use semantic versions | Predictable releases |
| Tag every deploy | Audit trail |
| Keep deploy notes | Faster incident response |
| Store artifacts offsite | Resilience |
| Keep production immutable | Avoid live edits |
| Record deploy timestamps | Helps incident response |
| Never commit ZIPs or secrets | Prevents accidental leaks |
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| Production differs from staging | Different code version | Compare tag or artifact checksum |
| CSS not updated | Cache | Purge LSCache and confirm versioning |
| Permissions issues | Wrong ownership | Use a consistent deploy user strategy |
Hands-On
- Initialize a Git repo for the child theme.
- Make one small change and commit it.
- Tag a release and package an artifact.
- Deploy to staging and roll back once.
- Record the Git SHA and artifact filename in a deploy note.
- Verify the deployed theme version matches your tag.
Quick Reference
deploy-cheatsheet.sh
cd /var/www/html/wp-content/themes/generatepress-child
git status
git tag
What's Next
- Next: Troubleshooting Child Themes
- Related: Security & Hardening