Installation

Basic

# Install Node.js
sudo apt-get install nodejs

# Install node package manager (npm)
sudo apt-get install npm

# Install git
sudo apt-get install git # yum install git-core

# Install hexo
npm install -g hexo-cli

Hexo site folder and install theme

In this blog, I will install freemind:

$ hexo init blog #blog is the folder to contains all hexo related files
$ cd blog
$ npm install
$ git clone https://github.com/wzpan/hexo-theme-freemind.git themes/freemind

Install hexo admin

npm install –save hexo-admin

Update site and theme _config.yml:

site._config.yml
title: Calvin's Home
subtitle:
description:
author: Calvin Yiu
email: calvin.ypn@gmail.com
language: default
timezone: Asia/Hong_Kong
...
i18n_dir: :lang
...
theme: freemind # Use freemind as the theme
...
deploy:
type: git
repo: https://github.com/pnyiu/pnyiu.github.io.git
theme._config.yml
links:
- title: "My Github"
url: http://www.github.com/pnyiu
intro: "My Github account."
icon: "fa fa-github"
- title: "My LinkedIn"
url: https://www.linkedin.com/in/pnyiu/
intro: "My Linkin account."
icon: "fa fa-linkedin"
...
widgets:
#- search
#- recent_comments
- category
- tagcloud
- recent_posts
- links
...
# Analytics
google_analytics:
enable: true
siteid: UA-103782633-2
baidu_tongji:
enable: false
siteid:
...
# share widgets
bdshare: false
jiathis: false

Create special pages: tags, categories and about pages

$ hexo new page tags
$ hexo new page about
$ hexo new page categories

Update the layout of tags/index.md and categories/index.md to tags and categories respectively.

$ tree -L 2
.
├── about
│   └── index.md
├── categories
│   └── index.md
└── tags
└── index.md
$ cat tags/index.md
title: Tags
layout: tags
---
$ cat categories/index.md
---
title: categories
layout: categories
date: 2017-08-02 16:51:54
---

Basic configuratons

Website icon - favicon

Create an image in png format and save it under the path specified in theme.config:

_config.yml
favicon: "favicon/favicon.png"

Install filters

hexo-filter-flowchart

npmhexo-filter-flowchart
npm install --save hexo-filter-flowchart
Optional

You may download the required Javascript files to your local server:

  1. Download flowchart.js and Raphaël.
  2. Copy the above two files to \themes\freemind\source\js (substitute freemind to match your theme folder name)

If you choose to use the files saved locally, then you have to modify site _config.yml:

_config.yml
flowchart:
raphael: /js/raphael.js # optional, the source url of raphael.js
flowchart: /js/flowchart.js # optional, the source url of flowchart.js
options: # options used for `drawSVG`

If it works, then you will see below flowchart:

Useful hexo or markdown syntax

Tag Plugins

Delimeter for excerpt and full content

<!-- more -->

Code

1
2
3
{% codeblock line_number:false %}

{% endcodeblock %}

Image

![](/images/2021-07-21 10_35_23-CodeBuild - AWS Developer Tools.png)

Front-matter

toc: true # Default: off
tags:
- Tag1
- Tag2
categories:
- Cat1
- Cat2

Commonly used commands


# Working in `source` branch
$ git status
On branch source
Your branch and 'origin/source' have diverged

# Start hexo server
hexo server # preview draft post, add --draft

# Generate a new page
hexo new "title" # e.g. hexo new "Use CI/CD on AWS"

# Generate draft page (will not generate and deploy)
hexo new draft "title"

# Generate static files
hexo generate

# Config for github (https)
deploy:
type: git
repo: https://github.com/pnyiu/pnyiu.github.io.git

# Config for github (ssh)
deploy:
type: git
repo: git@github.com:pnyiu/pnyiu.github.io.git

# Deploy to github
hexo deploy