简体   繁体   中英

How do I publish my React site on Github Pages?

I'm trying to publish a React app to Github Pages but all that pops up is a blank page when I attempt it. I'm new to React and not very bright.

Here is what my package.json looks like:

"homepage": "[myusername].github.io",
  "version": "1.0.0",
"description": "Personal website simulating Google Search interface, developed with React",  
  "keywords": [    
  "react",    
  "personal website",
"google",
  "portfolio"  
  ],  
  "main":"index.html",
  "dependencies": {
  "@fortawesome/fontawesome-svg-core": "1.2.36",
  "@fortawesome/free-regular-svg-icons": "5.15.4",
  "@fortawesome/free-solid-svg-icons": "5.15.4",
  "@fortawesome/react-fontawesome": "0.1.15",
  "@material-ui/core": "4.12.3",    
  "@material-ui/icons": "4.11.2",
  "prop-types": "15.7.2",  
  "react": "17.0.2",
  "react-dom": "17.0.2",
  "react-router-dom": "5.3.0",
    "react-scripts": "^5.0.1",  
  "react-select": "4.3.1"
    },

  
  "devDependencies": {
"@babel/runtime": "7.13.8",
  "gh-pages": "^3.2.3"
  },  
  "scripts": {
    "predeploy": "npm run build",
    "deploy": "gh-pages -d build",
  "start": "react-scripts start",
  "build": "react-scripts build",    
  "build-localhost": "PUBLIC_URL=/ react-scripts build",
    "test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"  
  },
  
  "browserslist": [  
  ">0.2%",  
  "not dead",  
  "not ie <= 11",  
  "not op_mini all"
  ]
}

I'm not sure what other info to provide, so I apologize in advance

Also, I didn't want to put my real name so that's why the homepage line looks like that here.

Please help?

I'm not sure if I get what you exactly mean. But if you want to push your existing project to github here is the steps:

1- create a new repository on github In Terminal, change the current working directory to your local project

2- then in your terminal write:

git init

Initialize the local directory as a Git repository.

3- git add. OR git add --all Commit the files that you've staged in your local repository.

4- git commit -m 'First commit' Commit the files that you've staged in your local repository.

5- git remote add origin <remote repository URL> Copy remote repository URL field from your GitHub repository, in the right sidebar, copy the remote repository URL.

In Terminal, add the URL for the remote repository where your local repostory will be pushed

6- git remote -v Sets the new remote.

7- git push origin master Push the changes in your local repository to GitHub


  • And if you mean by publish your project is deploying it you can follow these two links:

1- https://github.com/gitname/react-gh-pages

2- https://www.c-sharpcorner.com/article/how-to-deploy-react-application-on-github-pages/

the second one is a bit old but you can check the comments in bottom of the page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM