LinuxCommandLibrary

gh-pages

TLDR

Deploy dist folder to gh-pages

$ npx gh-pages -d [dist]
copy
Deploy with custom message
$ npx gh-pages -d [dist] -m "[Deploy to GitHub Pages]"
copy
Deploy to custom branch
$ npx gh-pages -d [dist] -b [docs]
copy
Deploy specific files
$ npx gh-pages -d [dist] -s "[*.html,*.css]"
copy
Deploy with custom remote
$ npx gh-pages -d [dist] -o [upstream]
copy

SYNOPSIS

gh-pages [options]

DESCRIPTION

gh-pages is an npm package that publishes files to a GitHub Pages branch. It automates pushing built static sites to the gh-pages branch for hosting.
The tool creates clean commits of your distribution folder to the target branch, making deployment a single command. It's commonly used in CI/CD pipelines.

PARAMETERS

-d, --dist dir

Directory to deploy.
-s, --src pattern
File pattern within dist.
-b, --branch branch
Target branch (default: gh-pages).
-o, --remote remote
Remote name (default: origin).
-m, --message msg
Commit message.
-u, --user name
Git user name.
-e, --email email
Git user email.
-a, --add
Add files, don't remove existing.
-t, --dotfiles
Include dotfiles.
--nojekyll
Add .nojekyll file.

PACKAGE.JSON SCRIPT

$ {
  "scripts": {
    "deploy": "gh-pages -d dist"
  }
}
copy

CAVEATS

Requires git and npm. Overwrites target branch. GitHub Pages settings must be configured. May need --nojekyll for some sites. Credentials needed for push.

HISTORY

gh-pages was created by Tim Schaub to simplify GitHub Pages deployments. It became a standard tool in the JavaScript ecosystem for static site deployment.

SEE ALSO

gh(1), git(1), npm(1)

Copied to clipboard