Deploy to Github Pages
January 05, 2020
Navigate to the Gatsby Project root folder
cd C:\[path-to-gatsby-project-folder]\
Install gh-pages
yarn add --dev gh-pages
or
npm install -D gh-pages
gatsby-config.js changes
Add the Github Repository name to pathPrefix
module.exports = {
pathPrefix: "/my-blog-starter",
}
package.json changes
Add the Github Repository name to homepage setting
"homepage": "https://snerks.github.io/my-blog-starter",
Add the Github Repository name to repository.url setting
"repository": {
"type": "git",
"url": "git+https://github.com/snerks/my-blog-starter.git"
},
scripts changes
Add a deploy script for gh-pages
"scripts": {
"deploy": "gatsby build --prefix-paths && gh-pages -d public"
}
Deploy to Github Pages
yarn run deploy
or
npm run deploy
Refer to this page, for more details on how to deploy to Github Pages.