Skip to main content

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

ConceptWhat it meansExample
Git repoVersion history for theme codegit init
Tags/releasesNamed snapshotsv1.2.0
ArtifactDeployable packagegeneratepress-child.tgz
RollbackRestore previous versionre-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:

  1. Re-deploy previous artifact
  2. Purge cache
  3. 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

MethodProsCons
Copy folder (rsync/scp)simpleeasy to drift
Deploy artifactreproducibleneeds packaging
CI pipelinerepeatablesetup cost

Best Practices

PracticeWhy
Use semantic versionsPredictable releases
Tag every deployAudit trail
Keep deploy notesFaster incident response
Store artifacts offsiteResilience
Keep production immutableAvoid live edits
Record deploy timestampsHelps incident response
Never commit ZIPs or secretsPrevents accidental leaks

Troubleshooting

SymptomCauseFix
Production differs from stagingDifferent code versionCompare tag or artifact checksum
CSS not updatedCachePurge LSCache and confirm versioning
Permissions issuesWrong ownershipUse a consistent deploy user strategy

Hands-On

  1. Initialize a Git repo for the child theme.
  2. Make one small change and commit it.
  3. Tag a release and package an artifact.
  4. Deploy to staging and roll back once.
  5. Record the Git SHA and artifact filename in a deploy note.
  6. 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