Build Blog with Hexo

Environment

  • node v19.8.1
  • yarn 3.2.4
  • hexo 6.3.0
  • netlify-cli 13.2.0

Install Hexo

inside Virtualbox share folder

1
2
3
4
yarn init && yarn add hexo
yarn hexo init blog
cd blog
touch yarn.lock && yarn

Config theme

1
2
3
4
5
6
7
8
9
10
11
12
# Default theme
# git clone --depth 1 https://github.com/hexojs/hexo-theme-landscape themes/landscape

# Cactus theme
## docs: https://github.com/probberechts/hexo-theme-cactus
git clone --depth 1 https://github.com/probberechts/hexo-theme-cactus themes/cactus

# Set theme in _config.yml
## I prefre light theme
theme: cactus
theme_config:
colorscheme: light

Hello world

1
2
3
yarn hexo new post hello
yarn hexo generate
yarn hexo server

Check http://localhost:4000/

Use Inkscape to create blog logo and ico from SVG

Use Netlify to depoly site

1
2
3
4
5
yarn add netlify-cli
yarn netlify login
yarn netlify deploy
# Ask for upload folder
yarn netlify deploy --prod --dir=public

Use yarn scripts for shortcut

Sumbit blog to Google Search Console

Choose URL prefix from Google Search Console

Download HTML File to source folder

set layout: false in HTML File’s front-matter

1
2
3
4
5
6
7
8
yarn add hexo-generator-sitemap

# config in _config.yml
sitemap:
path: sitemap.xml

## remember to change `url` in _config.yml
## check with https://x.x.x.x/sitemap.xml

Sumbit sitemap.xml url to Gootle Search Console

Ref: (24) 試著學 Hexo - SEO 篇 - Google Search Console