GitHub Pages can build your own site from scratch or generate one for your project.
Outline
- Create a repository
- Config SSH key
- Generate SSH key
- Add SSH key to ssh-agent
- Clone the repository
- Push it into GitHub
Create a repository
Head over to GitHub and create a new repository named “shensongjian.github.io”.
Config SSH key
Using the SSH protocol, you can connect and authenticate to remote servers and services. With SSH keys, you can connect to GitHub without supplying your username or password at each visit.
When you set up SSH, you will generate an SSH key and add it to the ssh-agent and then add the key to your GitHub account. Adding the SSH key to the ssh-agent ensures that your SSH key has an extra layer of security through the use of a passphrase.
Generate a new SSH key
Open Git Bash.
Generate private and public ssh key of your account.
1
$ ssh-keygen -t rsa -b 4096 -C "shensongjian@gmail.com"
Then press Enter three times as default configuration.
Add SSH key to the ssh-agent
Ensure the ssh-agent is running.
1
$ eval $(ssh-agent -s)
Add the SSH private key to the ssh-agent.
1
$ ssh-add {file_path}/id_rsa
Add the SSH public key to GitHub account: copy the contents of {file_path}/id_rsa.pub into the “Key” filed of SSH keys in your GitHub Settings.
Clone the repository
Go to the folder where you want to store your porject, and clone the new repository.
1 | $ git clone https://github.com/shensongjian/shensongjian.github.io |
Enter the project folder and add an index.html file.
1 | $ cd shensongjian.github.io |
Push it into github
1 | $ git add --all |
Done
It is done. Fire up a brower and go to https://shensongjian.github.io , “Hello World” will show in the main page.