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 static site to GitHub pages needs .nojekyll file #2029

Closed
bensalilijames opened this issue May 20, 2017 · 13 comments
Closed

Deploying static site to GitHub pages needs .nojekyll file #2029

bensalilijames opened this issue May 20, 2017 · 13 comments

Comments

@bensalilijames
Copy link
Contributor

bensalilijames commented May 20, 2017

Something I noticed deploying to GitHub pages is that the _next folder is by default not served by GitHub (404s) as mentioned here (underscored folders are ignored): https://github.com/blog/572-bypassing-jekyll-on-github-pages

Would it be possible for the _next folder to not begin with an underscore, or instead to add a note to the README mentioning this behaviour and the fact you need to add a blank .nojekyll file to the out dir otherwise?

@arunoda
Copy link
Contributor

arunoda commented May 21, 2017

@benhjames I think we should go with _next. But I'd like for such a note on on the README.
Could you send me a PR.
May be create a Wiki and add instruction to it. Then let's link that.

@brad-decker
Copy link

brad-decker commented Jun 1, 2017

@arunoda @benhjames having a problem with github pages.

  1. if .nojekyll is in out directory, github pages does not serve the default index.html file. I added one to the root of my project as well and it seemed to make it work. (I have .nojekyll in both out and root)
  2. Even still i get network request rejected by github pages for the _next files.

https://conciergeauctions.github.io/styled-material-components/

https://github.com/ConciergeAuctions/styled-material-components

@bensalilijames
Copy link
Contributor Author

@brad-decker I believe the best way to serve it is through a gh-pages branch with just the contents of the out directory (also with .nojekyll)

See how I do it here! https://github.com/benhjames/benjames.me/

And better instructions here: https://gist.github.com/cobyism/4730490

@brad-decker
Copy link

@benhjames the actual issue here is jekyll/jekyll#332 this ... it looks like _config.yml can set the base path for the site, however if we have a .nojekyll file does that mean that it'll ignore _config.yml? Is there a next.js way to set a base path?

@bensalilijames
Copy link
Contributor Author

Having the out dir hosted in a branch gets around that since the base path of the site is the root of the branch.

I don't think there's currently support for exporting a site that you want to host within a folder, but I may well be wrong!

@brad-decker
Copy link

@benhjames the base path for my site is https://conciergeauctions.github.io/styled-material-components/

the paths added for the build are relative urls that hit /_next/

that would resolve to https://conciergeauctions.github.io/_next/ not https://conciergeauctions.github.io/styled-material-components/_next/

Am i doing something wrong with my export setup? @benhjames @arunoda

@brad-decker
Copy link

@benhjames your site works due to custom cname/domain

@brad-decker
Copy link

Which i suppose is a totally fine workaround if nothing else works :P

@bensalilijames
Copy link
Contributor Author

Ahhh sorry I see, I assumed it was a GitHub user page rather than a project page! Yeah I can't really see a way to make that work right now other than via custom domain...!

@brad-decker
Copy link

Do you think a configuration option for custom root path url would be something usable? that would get appended ahead of /_next/ and static resources inside the index.html file?

@bensalilijames
Copy link
Contributor Author

Yeah I can see that being useful - @arunoda what do you think? Then you could host a static site with its root at e.g. https://mycoolsite.com/subfolder instead of being restricted to using https://mycoolsite.com

@brad-decker
Copy link

If this is something that'd be useful i'd like to take a stab at it. Would love to get involved with next.js contributing.

@brad-decker
Copy link

@benhjames @arunoda #2145 solves this. Technically the existing assetPrefix option works, but it then breaks next dev because my file structure doesn't match the one needed to make static site work on github.

@lock lock bot locked as resolved and limited conversation to collaborators May 11, 2018
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

3 participants