1

When I try and deploy my app to GitHub Pages, all I see is this page.: enter image description here

My actual project works on localhost, but for some reason I can't get it to display on GitHub Pages. To my package.json I've added "homepage": "https://username.github.io/my-site", and my scripts look like this:

    "scripts": {
    "predeploy": "npm run build",
    "deploy": "gh-pages -d build",
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },

The "username" in the homepage url is my actual GitHub username. Am I doing something wrong here? I think this is what the official GitHub tutorial suggested to do, unless I'm overlooking something.

torek
  • 448,244
  • 59
  • 642
  • 775
  • Probably, you need to configure the [sources folder](https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-from-a-branch) to point the pages to your build instead of readme. – Andrii Bodnar Dec 04 '22 at 10:40

1 Answers1

0

Creating build folder

  1. Run npm build to create production build of your website. A build folder containing the final version of your website will be created.
  2. Push this folder to Github.

Everytime you make a change to your code, you will have to generate the build folder again for the changes to be reflected on Github Pages.

Configuring package.json

In your package.json, you need to specify the homepage attribute:

"homepage": "https://username.github.io/my-repository/build"

If your package.json file is located in some sub-folder of your repository instead of root, then your homepage attribute must be modified accordingly:

"homepage": "https://username.github.io/my-repository/some-folder/build"

Notice that the homepage is pointing to the build folder.

Your website will be available at https://username.github.io/my-repository/build.

Bunny
  • 1,180
  • 8
  • 22