Search code examples
reactjsgithubgithub-pagescreate-react-app

React app deployed to GitHub Pages gives "Site not found"


I'm trying to deploy a create-react-app to GitHub Pages, but I'm getting a 404.

404

There isn't a GitHub Pages site here.

What I've done:

  • Created a user site repo named <username>.github.io
  • Added "homepage": "https://<username>.github.io" to package.json (as per the Create React App docs)
  • Installed the gh-pages package
  • Added and ran "deploy": "gh-pages -b master -d build" to scripts in package.json

The contents of /build folder is successfully pushed to master, but the site isn't accessible.

The repo's GitHub Pages settings simply says:

Your GitHub Pages site is currently being built from the master branch.

User pages must be built from the master branch.

I also tried some routing solutions (this and this) without making any difference, although I don't think they are ment to fix the problem I'm having.

I'm not sure how to troubleshoot this any further. Any ideas?


Solution

  • Ok, so apparently you have to choose a GitHub Pages theme (even though you're not using it) in order for the page to be published. This seems very strange to me, and from what I can tell it's not at all mentioned in the documentation. 🤷‍♂️