You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/deploy-gatsby.md
+38-1Lines changed: 38 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,4 +45,41 @@ This is a new problem when dealing with static sites built with React. React us
45
45
## Hosting on Amazon S3 and Cloudfront
46
46
If you decide to host your Gatsby site to S3 having Cloudfront as CDN you should edit on the Cloudfront panel the "Origin Domain Name" with the real URL of your S3 bucket: **examplewebsite.com.s3-website-eu-west-1.amazonaws.com** instead of the default one automatically suggested by Amazon **examplewebsite.com.s3.amazonaws.com**.
47
47
48
-
This is recommended for rendering correctly the post pages in the subfolders without typing the index.html path as described [here](https://forums.aws.amazon.com/message.jspa?messageID=314454).
48
+
This is recommended for rendering correctly the post pages in the subfolders without typing the index.html path as described [here](https://forums.aws.amazon.com/message.jspa?messageID=314454).
49
+
50
+
## Deploying on Github Pages
51
+
### Deploying a Project Page
52
+
Deploying Project on Github pages can be done with or without Custom Domain. If you choose to use the default setup (without Custom Domain), you will need to prefix your links (ex. gatsbypage.github.io/project-name/about-page - "/project-name" will be prefixed in all your links).
53
+
54
+
#### Without Custom Domain
55
+
First you have to add **gh-pages** as a dev-dependency and create an npm script command to **deploy** your project.
56
+
57
+
Run `npm install gh-pages --save-dev` or `yarn add gh-pages --dev` (if you have yarn installed). Alternatively, you can place this under *"devDependencies"* in you `package.json` file:
58
+
59
+
```
60
+
"devDependencies": {
61
+
"gh-pages": "^1.0.0",
62
+
}
63
+
```
64
+
65
+
Then run `npm install` or `yarn install`.
66
+
67
+
Add a **deploy** command in your `package.json` file.
In the `gatsby-config.js` add the path-prefix to be added to the links. The path-prefix should be the project name in your repository. (ex. `https://github.com/username/project-name` - your pathPrefix should be `/project-name`).
76
+
77
+
```
78
+
module.exports = {
79
+
pathPrefix: `/project-name`,
80
+
}
81
+
```
82
+
83
+
In your Github Repository, create a new branch `gh-pages`. Make sure that in `Settings` > `Github Pages` > `Source` your github pages branch is set to `gh-pages branch`.
84
+
85
+
After the setup, run `yarn deploy` or `npm run deploy`. Preview changes in your github page `https://username.github.io/project-name/`. You also can view your link under `Settings` > `Github Pages`.
0 commit comments