My personal GitHub pages created using React. Is it overkill? Probably, but I wanted to learn React.
For others that come across this and want to do something similar:
- Create your GitHub repository.
- Create your React app.
npx create-react-app <name>
- Navigate to the React app directory.
- For local development, you can run
npm start
. - Install
gh-pages
package.
npm install gh-pages --save-dev
- Modify package.json
- Add a new field
homepage
field with the GitHub pages URL for the repository created in step 1. - Within the
scripts
block, add apredeploy
script and adeploy
script.
- Add a new field
# package.json
{
"name": "tktong.github.io"
...
"homepage": "https://tktong.github.io"
...
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
}
}
- When ready, deploy GitHub page.
npm run deploy