HexoBlog Development Log (Part 2/4)
This article documents and explains how my HexoBlog was deployed to Github Pages step by step, from zero to present, welcome for you to reference. Here is My HexoBlog.
Part 1 - Preparation
- Having a Git account
- Install nodejs and Git
- Install and Initialize Hexo Blog
Part 2 - Basic configuration and blog deployment
Basic Blog configuration
Deploy a blog for the first time with GitPage
Install blog theme - “Butterfly”
Develop a own picture hosting (PicGo + GitHub)
Part 3 - Blog maintain and GitHub version control
- Use of Hexo command
- Deploy a blog with theme
- Push source file to GitHub
Part 4 - Advanced configuration based on “Butterfly” theme
- Config blog attributer and Customize blog style with “Butterfly”
Basic blog configuration - _config.yml
Please always refer to Hexo official Doc - EN Hexo - Configuration and CN Hexo - Configuration.
Open
.../YourBlogSource/_config.yml
with any text/code editor (sublime text, Atom and any IDE & code editor).#Site
: define basic state of the HexoBlog. Every attribute have not fix format.1
2
3
4
5
6
7
8
9# Site
title: Becoze's Blog
subtitle:
description: About me <br> Name - Becoze, Nick or Liyuan Liang. <br> Language - English, Mandarin, Cantonese. <br> <i class='fas fa-map-marker-alt'></i> NSW, Sydney
keywords: ---Stay inquisitive---
author: Becoze
language: en
timezone: ''
email: liyuanliang20@outlook.comUser of fas icon
<i class='fas fa-map-marker-alt'></i>
, please refer to HexoBlog Development Log (Part 4) - Advanced configuration based on “Butterfly” theme#URL
: define global url to the blog after we deploy.url
: must following the formathttps://<GitHub-Username>.github.io
. Note: not repo url.
1
2# URL
url: https://becoze.github.io#Deployment
: define deploy method. Re-request of blog GitPage-deployment.- type:
git
, fixed - repo:
https://github.com/becoze/becoze.github.io.git
, must use your url of the repo. - branch:
main
, main or any branch
1
2
3
4
5# Deployment
deploy:
type: git
repo: https://github.com/becoze/becoze.github.io.git
branch: main- type:
Deploy a blog for the first time with GitPage
Install Hexo Blog deployer:
npm install hexo-deployer-git --save
at blog root directory /HexoBlogDeployment: run following using Git Bash at blog root directory /HexoBlog
1
2
3$ hexo clean
$ hexo g
$ hexo deployPossible error (optional)
1
2
3
4
5
6
7
8
9
10
11
12Please tell me who you are.
Run
git config --global user.email “you@example.com”
git config --global user.name “Your Name”
to set your account’s default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got ...)
error: src refspec HEAD does not match any.
error: failed to push some refs to(your ...github.io) solution:
- run
git config --global user.email "<you@example.com>"
, your GitHub email address - run
git config --global user.name "<username>"
, your GitHub username
- run
Install and apply blog theme - “Butterfly”
Developed own Image hosting - “PicGo + GitHub”
Tutorial Bilibili 使用picgo+github搭建免费个人图床
To store able to image. Create a new Public repo together a
README.md
file in GitHub with any name .Obtain token: GitHub setting –> Developer setting –> Personal access tokens –> Generate new token
- Note: any (e.g. “blogPictureHosting”)
- Expiration: any (recommend 60 days)
- Select Scopes:
repo
: select all, MUST- all other: remain deselect
Make sure to copy your personal access token before “Finish”. You won’t be able to see it again!
Download PicGo exe. file from GitHub at PicGo Release
PicGo-Setup-2.3.0-x64.exe for Windows
PicGo-Setup-2.3.0-x64.dmg for Mac iOS
Image hosting setting 图床设置 (Host setting) –> GitHub图床 (GitHub Host setting)
Repo name (设定仓库名): The name of repo just created in step 1
1
username/repo-name
Branch name (设定分支名): The branch name where to store pictures. (
main
by default)1
main
Token setting (设定Token): the token from step 2
Repo path (指定储存路径): the path/folder where to store pictures.
1
img/
Customize domain name (设定自定义域名): Remain empty. It can speed up static resource loading if needed.
6. Start up load image !!!