Skip to content

tktong/tktong.github.io

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tktong.github.io

My personal GitHub pages created using React. Is it overkill? Probably, but I wanted to learn React.

Creating your own GitHub pages using React.

For others that come across this and want to do something similar:

  1. Create your GitHub repository.
  2. Create your React app.
npx create-react-app <name>
  1. Navigate to the React app directory.
  2. For local development, you can run npm start.
  3. Install gh-pages package.
npm install gh-pages --save-dev
  1. Modify package.json
    1. Add a new field homepage field with the GitHub pages URL for the repository created in step 1.
    2. Within the scripts block, add a predeploy script and a deploy script.
# 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"
  }
}
  1. When ready, deploy GitHub page.
npm run deploy