Skip to content
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

deploying to github pages as subdirectory #478

Closed
stopachka opened this issue Aug 23, 2016 · 3 comments
Closed

deploying to github pages as subdirectory #478

stopachka opened this issue Aug 23, 2016 · 3 comments

Comments

@stopachka
Copy link

stopachka commented Aug 23, 2016

I have a small project with create-react-app, which I wanted to host on github pages. It would be:

stopachka.github.io/my-project

The help in our tutorial was awesome. However, when loading the project, assets are not correctly found.

In the generated index.html, we have ->

<script type="text/javascript" src="/static/js/main.ce66e420.js"></script>

This will direct github-pages too

https://stopachka.github.io/static/js/main.ce66e420.js

which return a 400. It should instead direct to ->

stopachka.github.io/my-project/static/js/main.ce66e420.js

Ideas:

  1. Make it so the source path does not have the / prepended to it.
  2. Find simple way to tell github-pages to do the right thing, or to prepend /my-project/ to the source path through some option
  3. If this is something that we don't want to support out of the box, we can tell users to eject, and write some quick instructions in the docs
@stopachka stopachka changed the title deploying to github pages as subdirector deploying to github pages as subdirectory Aug 23, 2016
@gaearon
Copy link
Contributor

gaearon commented Aug 23, 2016

I think the tutorial you linked to mentions the fix in the first sentence 😉 .

Open your package.json and add a homepage field:

 "homepage": "http://myusername.github.io/my-app",

If you do this, Create React App will know to use /my-app as root URL.

@gaearon gaearon closed this as completed Aug 23, 2016
@gaearon
Copy link
Contributor

gaearon commented Aug 23, 2016

Clarified in the doc: 6aabe7e.
The most recent version also explains this behavior after build:

screen shot 2016-08-23 at 23 21 24

@stopachka
Copy link
Author

Ah, nice, thanks for the clarification @gaearon -- initially thought it was just meant as a flag to output the instructions. Super nice touch :)

@lock lock bot locked and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants