Ready for deployment
If everything goes well, this will be the last post of my gatsby-blog series It's been a while for me to post something new Recently, I participated a frontend campaign from hex-school It's keep me busy for weeks And I will put my project on here, soon or later, after I finish them.
Back to today's topic : Deployment what I'm going to share today is quite simple since we have done all the coding part now it's time to put it online
There are so many resource we can use like Netlify, heroku, vercel, github-page they all can help you deploy easily and this time I choose github-page to do the deployment
Basically, I follow the tutorial and it offer three ways to deploy with github-page
- to a path like
username.github.io/reponame/
(need to set pathPrefix) - to a subdomain based on your username or organization name
username.github.io/reponame/
- to the root subdomain at username.github.io, and then configured to use a custom domain
here I choose second one
steps for github-page deployment
- install package
gh-pages
- add a script in package.json
// notice that GitHub Pages need main branch to deploy, so you need to reserve this branch namefor github-page
"scripts": {
"deploy": "gatsby build && gh-pages -d public -b main"
}
- in cmd run
npm run deploy
- you are able to see it online(maybe after 5 min)
# little problem I met (about github remote)
what I met here is in my project remote when I use git pull/push it come out this error message:
remote: Support for password authentication was removed on August 13, 2021.
Please use a personal access token instead.
looks like I can not use the old way to connect to github 🤔
solution is to use access token
so ...here's how to make a token:
in github, click your avatar > select Setting
in sidebar of setting page, select Developer Settings
on left sidebar, select Personal access tokens (Tokens classic)
click generate token(classic)
copy this token then open the project cmd
change project remote to https://<tokenhere>@github.com/<user>/<repo>.git
here's how I change remote
git remote set-url origin https://<tokenhere>@github.com/<user>/<repo>.git
then I am able to use git pull/push
this is today's sharing 👋