-
-
Notifications
You must be signed in to change notification settings - Fork 27k
Add new github docs folder hosting option #520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f8cc3b7
50e8f77
650bd43
abebfca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,15 +130,14 @@ function build(previousSizeMap) { | |
console.log('You can control this with the ' + chalk.green('homepage') + ' field in your ' + chalk.cyan('package.json') + '.'); | ||
console.log(); | ||
console.log('The ' + chalk.cyan('build') + ' folder is ready to be deployed.'); | ||
console.log('To publish it at ' + chalk.green(homepagePath) + ', run:'); | ||
console.log('To publish it at ' + chalk.green(homepagePath) + ' using the docs/ folder, run:'); | ||
console.log(); | ||
console.log(' ' + chalk.cyan('git') + ' commit -am ' + chalk.yellow('"Save local changes"')); | ||
console.log(' ' + chalk.cyan('git') + ' checkout -B gh-pages'); | ||
console.log(' ' + chalk.cyan('git') + ' add -f build'); | ||
console.log(' ' + chalk.cyan('rm') + ' -rf docs/'); | ||
console.log(' ' + chalk.cyan('mv') + ' build/ docs/'); | ||
console.log(' ' + chalk.cyan('git') + ' add docs -A'); | ||
console.log(' ' + chalk.cyan('git') + ' commit -am ' + chalk.yellow('"Rebuild website"')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fine to keep for consistency so people don’t think it matters and stress over it. |
||
console.log(' ' + chalk.cyan('git') + ' filter-branch -f --prune-empty --subdirectory-filter build'); | ||
console.log(' ' + chalk.cyan('git') + ' push -f origin gh-pages'); | ||
console.log(' ' + chalk.cyan('git') + ' checkout -'); | ||
console.log(' ' + chalk.cyan('git') + ' push origin master'); | ||
console.log(); | ||
} else if (publicPath !== '/') { | ||
// "homepage": "http://mywebsite.com/project" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -850,16 +850,17 @@ Open your `package.json` and add a `homepage` field: | |
**The above step is important!** | ||
Create React App uses the `homepage` field to determine the root URL in the built HTML file. | ||
|
||
Now, whenever you run `npm run build`, you will see a cheat sheet with a sequence of commands to deploy to GitHub pages: | ||
To host your app using the `/docs` folder you just need to move the `build` folder to a new `docs` folder, check in the new `docs` folder and set the GitHub Pages Source to the `master branch /docs folder` setting. [Read more here](https://help.github.com/articles/configuring-a-publishing-source-for-github-pages/#publishing-your-github-pages-site-from-a-docs-folder-on-your-master-branch) about setting up the GitHub settings. | ||
|
||
You can use the following sequence of commands to clear out the old docs folder, move the build to the docs folder, and then check it in to the master branch: | ||
|
||
```sh | ||
git commit -am "Save local changes" | ||
git checkout -B gh-pages | ||
git add -f build | ||
rm -rf docs/ | ||
mv build/ docs/ | ||
git add docs -A | ||
git commit -am "Rebuild website" | ||
git filter-branch -f --prune-empty --subdirectory-filter build | ||
git push -f origin gh-pages | ||
git checkout - | ||
git push origin master | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An extra space between |
||
``` | ||
|
||
You may copy and paste them, or put them into a custom shell script. You may also customize them for another hosting provider. | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
./docs/CNAME
file exists, we should preserve it. (Our current deployment code accidentally removes it, see #654.) When the custom domain is edited trough the GitHub Pages settings, GitHub saves it in this file.