-
Create the
gh-pagesbranch and initialize it with nothing except a.gitkeepfile. -
Add
gh-pages/folder in.gitignoreto keep git history clean. -
From the
masterbranch, clone thegh-pagesbranch into thegh-pagesfolder:
$ git clone <repo> --branch gh-pages gh-pages- Create a deploy script in
package.json.
For instance for a little project of mine using the angular CLI:
"deploy": "rm -f gh-pages/* && ng build --base-href 'https://USERNAME.github.io/PROJECT/' && cp dist/* gh-pages/ && cd gh-pages && git add --all && git commit -m \"Release at $(date)\" && git push"That's all.
More ideas here.