hexo安装

1
sudo npm install hexo-cli -g

若出现npm ERR! Unexpected end of JSON input while parsing near '...ublish-latest":"^1.1.'

1
sudo npm cache clean --force

ubuntu 16.04 nodejs 版本低会出现

1
2
3
4
5
6
7
8
9
10
11
12
13
/usr/local/lib/node_modules/npm/bin/npm-cli.js:79
let notifier = require('update-notifier')({pkg})
^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3

先卸载nodejs,然后安装稳定最新版

1
2
3
4
5
6
sudo apt-get remove --purge nodejs
curl -sL https://deb.nodesource.com/setup_8.x | sudo bash -
sudo apt-get update
sudo apt-get install nodejs
sudo npm install npm -g
npm --version

测试安装结果

1
2
3
4
hexo init blog
cd blog
npm install
hexo s

浏览器访问: localhost:4000

部署到github

  1. 安装 hexo-deployer-git
    1
    sudo npm install hexo-deployer-git --save
  2. _config.yml(如果有已存在的请删除)添加如下配置:
    1
    2
    3
    4
    5
    6
    7
    deploy:
    type: git
    repo: https://github.com/<username>.github.io # example, https://github.com/hexojs/hexojs.github.io
    branch: <YourBranch>
    message: <update>
    name: <username>
    email: <youremail@xxx.com>
    运行
    1
    hexo clean && hexo deploy
    查看 username.github.io 上的网页是否部署成功。

hexo d 部署时在Copying files from public folder就停掉的问题

1
2
3
4
5
$ hexo d
INFO Validating config
INFO Deploying: git
INFO Clearing .deploy_git folder...
INFO Copying files from public folder...

用下面指令解决

1
2
3
cd blog
npm un hexo-deployer-git
npm i hexojs/hexo-deployer-git

主题使用

concise

预览地址

1
2
3
4
5
6
npm install hexo-renderer-less --save
npm uninstall hexo-renderer-stylus --save
git clone https://github.com/sanonz/hexo-theme-concise.git themes/concise
cp themes/concise/_config.example.yml themes/concise/_config.yml
#vim _config.yml #改theme: concise
#vim themes/concise/_config.yml #个性化博客主题页面

Hexo-Theme-AirCloud

预览地址

1
2
3
4
5
git clone https://github.com/aircloud/hexo-aircloud-blog.git --recursive
cd hexo-aircloud-blog
git clone https://github.com/aircloud/hexo-theme-aircloud.git themes/aircloud
npm install
hexo s

Hexo引用站内文章

1
2
3
# 假设有篇文章 hexo-github-blog.md
{% post_link hexo-github-blog %} #使用原文章title名字
{% post_link hexo-github-blog 显示的名字 %} #显示新名字