🚀Deploying on GitHub pages
launching a project on GitHub pages
GitHub provides a convenient way to store our app for free on their own servers and "github.io" domain (or even our own):
Connecting the local repository with the remote
If we have not yet already, let us run these commands in Terminal:
$ git init
$ git remote origin add (remote url on github)
$ git add -A
$ git commit -m "pushing initial version"
$ git push origin master
Installing the gh-pages utility
Then, let's set up the gh-pages
package as a "dev dependency":
$ npm install gh-pages --save-dev
Editing package.json for deployment
Add this property to the
package.json
file, replacingyourname
andyourrepo
with the obvious:
Then, within the
scripts
property:
Overall, the package.json
file should look something like:
Deploying
In Terminal, we can run just one-liner command:
Setting up the remote repository for GitHub pages
On GitHub:
Create a new remote repository (and note down its URL)
Go into the repository's Settings
Go to the section GitHub Pages
Under Source
Pick "Branch: gh-pages"
leave the folder at **** /(root)
Save
Wait a few seconds or a few minutes to see the page live on yourname.github.io/yourrepo
Re-deployment
For every time that we wish to re-deploy, we just run these commands:
$ git add -A
$ git commit -m "pushing another version"
$ git push origin master
$ npm run deploy
With command aliasing we can turn those four commands into probably just one or two commands!
Last updated