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

404 when I deploy #351

Closed
Bam92 opened this issue Apr 17, 2020 · 5 comments
Closed

404 when I deploy #351

Bam92 opened this issue Apr 17, 2020 · 5 comments

Comments

@Bam92
Copy link

Bam92 commented Apr 17, 2020

I am wondering if there is a bug in the package. Since I deployed my site I am still getting Not found error.

I am using ver 2.2.0. This is my script:

const ghPages = require("gh-pages") 

ghPages.publish(
    'public',
    {
      branch: 'master',
      repo: 'https://github.com/Bam92/abelmbula.git',
    },
    () => {
      console.log('Deploy Completed!')
    }
  )


When I run my custom command to deploy (npm run deploy:gh-pages) I get the message Deploy Completed!, but when I go online I get 404 error.

What's wrong?

@kyleratti
Copy link

kyleratti commented Apr 17, 2020

Based on the code above, it looks like you are committing your project's public folder to the master branch. By default, GitHub Pages is configured to serve from the gh-pages branch. I do see that your repository's GitHub Pages site is returning 404, so I suspect that is your problem.

You would either need to change the branch you're deploying to or configure the Bam92/abelmbula library to use your master branch for GitHub Pages. The former seems to be preferred by most people for static sites.

@Bam92
Copy link
Author

Bam92 commented Apr 18, 2020

From my understanding of the doc the package creates gh-pages branch if you don't have any.

Anyway, I tried to configure Github pages to use my master branch (though I'd like to use the developer branch as source. when I run deploy script and visit the site, I have just the readme file.

@kyleratti
Copy link

kyleratti commented Apr 18, 2020

You are technically correct (the best kind!) but your code is overriding that behavior. The default is indeed to create the gh-pages branch for you and deploy your code there, however you are explicitly stating to push it to the master branch instead:

const ghPages = require("gh-pages") 

ghPages.publish(
    'public', // the first argument is the local folder to publish
    {
      branch: 'master', // <== this is explicitly telling the library to publish the folder stated above to this branch
      repo: 'https://github.com/Bam92/abelmbula.git',
    },
    () => {
      console.log('Deploy Completed!')
    }
  )

I also see it loading your README.md now that you've changed the GitHub Pages branch to master. If you want to use develop for your source code and master for the GitHub Pages code, your master branch should be filled with the contents of your public/ folder when a deploy publishes. Because that branch is still filled with your source code, it suggests we are missing an error message and the deploy actually isn't completing successfully.

I would recommend modifying your script to display the error message in the callback as I think it'll reveal the missing piece here. Something like this should suffice:

const ghPages = require("gh-pages") 

ghPages.publish(
    'public', // the first argument is the local folder to publish
    {
      branch: 'master', // <== this is explicitly telling the library to publish the folder stated above to this branch
      repo: 'https://github.com/Bam92/abelmbula.git',
    },
    (err) => {
      if(err) console.error(err)
      else console.log('Deploy completed!')
    }
  )

@kyleratti
Copy link

I created a pull request for the above suggestion and also fixed the target branch (it was different in the script vs. this issue)

@Bam92
Copy link
Author

Bam92 commented Apr 24, 2020

I've fixed my problem, so I've to close this issue. For those who might need the solution, know that I worked with @kyleratti (thank you so much :)). In short, do create your gh-pages branch yourself, I've noticed that the package does not create one. And use that branch as the source for your site. From my knowledge, Github Pages does not allow other sources than master or gh-pages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants