Categories
Mastering Development

Deploying personal github pages (React App) just shows Readme

I’m trying to deploy a user-github page at username.github.io. So not a project page. However, after following steps online, I’m met with just the readme.md.

The existing questions about problems releated to this are for github pages (username.github.io/someproject), whilst this is just for username.github.io.

Procedure

npm install gh-pages --save-dev

in package.json:

  "homepage": "https://myusername.github.io",
  "name": "homepage",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@material-ui/core": "^4.9.14",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "bootstrap": "^4.4.1",
    "react": "^16.13.1",
    "react-bootstrap": "^1.0.1",
    "react-dom": "^16.13.1",
    "react-scripts": "3.4.1",
    "react-spring": "^8.0.27"
  },
  "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"

  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "gh-pages": "^2.2.0"
  }
}

Then push to the gh-pages pages branch using

npm run deploy which says that my page is published. The branch gh-pages exist on github.

In this step from https://blog.usejournal.com/how-to-deploy-your-react-app-into-github-pages-b2c96292b18e
enter image description here

I’m not able to change the source, so I try to publish to the master branch with gh-pages:

publishfile.js:

var ghpages = require("gh-pages");

ghpages.publish(
  "dist",
  {
    branch: "master",
    repo: "https://github.com/StianIsmar/StianIsmar.github.io/",
  },
  () => {
    console.log("Published...");
  }
);

However, I still get the README.md when I go to the url for the user page. It does not look master is changing after I run node publishfile.js. enter image description here

Leave a Reply

Your email address will not be published. Required fields are marked *