npm install -g gatsby-cli
gatsby new my-blog https://github.com/zhalice2011/blog
cd my-blog
gatsby develop
Your site is now running at http://localhost:8000. Open the my-gatsby-site directory in your code editor of choice and edit src/pages/index.js. Save your changes, and the browser will update in real time!
Step 0
please replace zhalice2011
to your github username
git remote add origin git@github.com:zhalice2011/zhalice2011.github.io.git
Step 1
Start by pushing a gh-pages branch. The initial contents of the branch doesn't matter since it will be overridden with the build artifacts on the next step of this guide.
git checkout -b gh-pages
git push -u origin gh-pages
Step 2
In gatsby-config.js
, change the pathPrefix
to the name of your Github repository
module.exports = {
pathPrefix: `/`,
...
}
Step 3
npm run deploy
If everything goes well, you should be able to access https://zhalice2011.github.io/
If you set pathPrefix /blog
module.exports = {
pathPrefix: `/blog`,
...
}
you should be able to access https://zhalice2011.github.io/blog