Environments:

  • Windows 10 64-bit
  • git 2.28.0.windows.1
  • Node.js v16.14.2
  • npm 8.5.0

Prepare

  • Download and install git.

  • Download and install Node.js.

Github

Register Github account and Create a new repository

  • Goto the Github page and register your account.

01

  • Click the New button in the webpage left side.

02

  • Input data.

    03

    1. Enter Repository name. You need to replace username with your username.

      You can see your username in the upper right corner.04

    2. Check Add a README file [Optional]

    3. Click Create repository

SSH Key

  • Right-click anywhere and click Git Bash Here.

    05

  • Enter ssh-keygen -t ras -C EmailAddress (replace EmailAdress with your email adress).

    06

    After, use the default settings (press Enter) as shown in the following image.

    07

  • Enter cat ~/.ssh/id_rsa.pub. Copy the string of text that is displayed.

    08

  • Goto the SSH key setting on Github.

    09
    10

  • Click New SSH key.

    11

  • Input Title (custom) and paste the Key that you just copied.

    12

  • Finally, you’re done setting up Github.

    13

Hexo

  • Everything is entered in Git Bash.

  • You can also check out the documentation on Hexo.

Install Hexo

1
npm install hexo-cli -g  

Setup your blog

1
2
hexo init GithubBlog  
cd GithubBlog

You can find the GithubBlog folder.

1
2
3
4
5
6
7
8
9
# Folder structure.  
.
├── _config.yml # configuration
├── package.json
├── scaffolds # templates folder
├── source # post & page folder
| ├── _drafts # draft folder
| └── _posts # blog post folder
└── themes # theme folder

Create a new post

1
hexo new post "new post"  

Local Server

1
hexo s  

Open your browser and type http://localhost:4000/.

14

Deploy to Github

  • Install a deployment plugin.

    1
    npm install hexo-deployer-git --save  
  • Goto the GithubBlog folder, open the _cofig.yml file, locate the deploy and enter the following

    1
    2
    3
    4
    deploy:  
    type: git
    repo: [email protected]:username/username.github.io.git
    branch: master

    SSH link entered in the repo can be retrieved from the repository, as shown below

    15

  • Generate & Deploy

    1
    2
    3
    hexo g  
    hexo d -m "First"
    # -m "" You can enter a description of the content of this update
  • In Github repository.

    16

  • Finally, type in your browser: username.github.io.

17

Find theme (Optional)

You can find your favorite theme on themes that will make your Blog look better.

The theme I’m using is Butterfly.

For details, please refer to the theme documentation.