The GitHub add-on is a little different from the other publishers. It does not upload to a host. It writes the prepared site to a repository, one branch per environment, and lets GitHub Pages, Netlify or Cloudflare Pages serve that branch.
That makes it the foundation for the two host guides in this section, and the shortest route to a site on GitHub Pages.
What the add-on does
Each environment points at one repository, one branch and one address. Publishing copies the site from WordPress once, then builds a commit per environment and sends it as a single Git push.
Only blobs the repository does not already have are sent. That includes blobs on your other StaticScope branches, so the second environment is cheaper than the first.
Before you start
- StaticScope and the GitHub add-on, both active.
- A repository. A new, empty one is best, and it can be private.
- A fine-grained token with Contents: Read and write on that repository.
- For GitHub Pages: a public repository, unless your GitHub plan covers Pages on private ones.
Create the repository
Create it on GitHub and leave it empty. If GitHub offers to add a README, a licence or a .gitignore, accept: those files are kept when StaticScope publishes. The same is true of a repository you already have, as long as you give the site a branch of its own.
A publish replaces everything on its branch except a short list of kept files. If the branch holds a theme or anything else you care about, choose another branch before you save the environment. The screen tells you what is already on a branch and asks before replacing files it did not put there.
For GitHub Pages, one repository serves one site. Staging and production therefore need two repositories if Pages is the host for both.
Create the token
Open StaticScope → Add-ons, choose GitHub and use the Create a token button. It opens GitHub’s token form with a name, a description, a one-year expiry and the contents permission prefilled where GitHub allows it.
- Under Repository access, choose Only select repositories and pick the site’s repository.
- Under Permissions, set Contents to Read and write. It only appears once a repository is selected. GitHub adds Metadata automatically, which is expected.
- Check the expiry is still a year away, then select Generate token and copy it.
For an organisation’s repository, set Resource owner to the organisation even if it is already showing. Otherwise the token belongs to your account and cannot see the repository. Choosing the organisation can clear the expiry date, so check it again. If the organisation approves tokens, an owner has to approve this one before publishing works; you can connect it in the meantime.
The add-on encrypts the token with the site’s salts before storing it and never shows it again. STATICSCOPE_GITHUB_TOKEN in wp-config.php overrides the saved token, and then the screen can only point at the file. Removing a token offers to cancel it on GitHub as well.
Connect the token
Paste the token into the setup screen and select Connect. The add-on checks it against GitHub and greets you by account name. A token that fails here is usually the wrong resource owner, the wrong repository selection or a missing contents permission.
Add an environment
An environment is a repository, a branch and an address. Most sites need one; add Staging or UAT when you want a copy to look at first.
| Field | What it wants |
|---|---|
| Name | Up to 40 characters. Production, Staging, UAT. |
| Hosted on | GitHub Pages, Cloudflare, Netlify or somewhere else. Only changes the setup steps you are shown. |
| GitHub repository | owner/name, picked from the repositories the token can see. |
| Branch | Letters, numbers and . _ - /. No spaces, no .., no trailing dot or slash, no .lock. |
| Address | The address visitors use. Hostname only, no path or query. Stored with a trailing slash. |
| This is the live site | One environment only. Saving a new live environment clears the old one. |
| Publish here when a scheduled post goes live | Adds this environment to scheduled publishing. |
| Also publish from background jobs | For developers. Used by staticscope_deploy and wp staticscope deploy. |
Saving checks that the token can reach the repository, so a wrong pick is caught here rather than at the first publish. The address must be the address where the site will live. Links in the prepared copy are absolute, and the add-on does not check that address against the build for you. Change the domain and you need to build again, or the old domain stays in every link, canonical tag and sitemap entry.
First publish
Build the site on StaticScope’s Overview, then open Publish site. Each environment has a card with a Publish button. Publish once before you set up the host, because the branch has to exist before GitHub Pages or Cloudflare can point at it.
After that, publish to Staging, check it, then publish to Production. The live environment is sorted last in a multi-environment publish, so the preview files left on disk match the live address.
Turn on GitHub Pages
- Open the repository on GitHub, then Settings → Pages.
- Under Build and deployment, set Source to Deploy from a branch.
- Choose the branch and
/ (root), then save. - Wait for the first Pages build, then open the address GitHub gives you.
Add a custom domain under the same Pages settings and create the DNS records GitHub asks for. A custom domain also avoids the folder-style address a project site gets, which does not suit a static build with absolute links.
What each publish does
Every publish is one commit on the environment’s branch. StaticScope recognises its own branches by the trailer it puts at the end of each commit message, which is how the screen can tell you whether a branch holds your site or someone else’s work.
A publish replaces the branch contents apart from a kept list: CNAME, _redirects, _headers, netlify.toml, vercel.json, wrangler.jsonc, .well-known/, .github/, licence and readme files, and a few other host config files. .nojekyll is always written so GitHub Pages serves the files as they are.
Non-live environments get a noindex, nofollow meta tag with a data-staticscope-environment attribute. robots.txt is left alone. The live environment gets nothing added.
For a Cloudflare host, the add-on also patches wrangler.jsonc so Workers static assets use the site’s own 404 page, and writes .assetsignore so .git is not uploaded as an asset. That patch can be turned off with the staticscope_github_patch_wrangler filter, which returns true by default. The filter is not in the readme, so treat it as an escape hatch rather than a supported setting.
Branches, undo and cancel
Undo puts the tree back as it was before the last publish, as a new commit. It only goes back one step, it refuses if the branch has moved since, and it does not change WordPress, so the next publish brings the newer files back.
Cancel works until the push starts. Finding pages, copying them, preparing each environment and even the check before the push can all be stopped. Once the push begins it is one atomic update and cannot be interrupted.
Only one publish runs at a time, enforced by a database lock that is released if PHP dies. If the browser disconnects, the publish carries on.
Scheduled posts
Tick Publish here when a scheduled post goes live on the environment, and WordPress publishes to it when a post’s scheduled time arrives. Failures retry every ten minutes, up to six times, then appear on the Dashboard. A local site needs the Publish site screen open and the computer awake for this to happen on time.
When it fails
| Symptom | Cause |
|---|---|
| “GitHub didn’t accept the token” | The token was revoked, deleted or has expired. Paste a new one. |
| “The token doesn’t have permission…” | Contents is not set to Read and write, or the repository was not selected on the token. |
| 404 from GitHub | The token’s resource owner does not match the repository’s owner, or an organisation has not approved the token. |
| The push is rejected | Branch protection. Publish to another branch, or let the token’s account push to this one. |
| “…is bigger than 100 MB” | GitHub’s per-file limit. Leave the file out of the static site in StaticScope’s settings. |
| “The branch changed while StaticScope was publishing” | Something else committed to the branch. Publish again to include it. |
| The site has old links | The build was made for a different address. Build again. |
Files between 50 MB and 100 MB publish with a warning. A repository that grows with every publish eventually hits GitHub’s practical limits, and GitHub Pages sites are capped at 1 GB.
Who can publish
Setup needs manage_options. Publishing uses a separate capability, staticscope_publish_site, which maps to publish_pages by default, so editors can publish without touching the token. Change it with the staticscope_github_publish_capability filter if that is too loose for your site.
WP-CLI
wp staticscope github status
wp staticscope github environments --format=table
wp staticscope github publish production --yes
wp staticscope github publish --all
wp staticscope github undo production
publish asks before touching a live environment unless you pass --yes, reports added, changed and removed files per environment, and exits with status 1 if any environment failed. status also prints the token’s expiry, the next scheduled post and any posts that went live without a publish.
The screen and the CLI share the same history, so an undo in the terminal shows up on the Publish site screen.