0%

Hexo 安装教程

依赖软件

Git 安装[^1]

  • Windows: 下载并安装 git。
  • Mac: 使用 Homebrew, MacPorts or installer 安装。
  • Linux (Ubuntu, Debian): sudo apt-get install git-core
  • Linux (Fedora, Red Hat, CentOS): sudo yum install git-core

Git 密钥生成

1
ssh-keygen -t rsa -C "your-email-address"

Node.js 安装

Hexo 安装

启动系统命令行终端,使用 npm 命令安装 Hexo

1
npm install -g hexo-cli

更换主题

项目根目录下执行下面的命令下载hexo-theme-next主题

1
git subtree add -P themes/hexo-theme-next  https://github.com/theme-next/hexo-theme-next.git  v6.4.1 --squash

_config.yml修改theme配置

1
2
3
...
theme: hexo-theme-next
...

插件安装

  1. hexo-renderer-markdown-it-plus

Hexo 的默认渲染插件是 hexo-renderer-marked,缺少很多功能,比如不支持 GFM、上下标、注脚、emoji 等,使用 hexo-renderer-markdown-it 加强版补足。[^2]

1
2
npm un hexo-renderer-marked --save
npm i hexo-renderer-markdown-it-plus --save
  1. hexo-math

安装hexo-math插件

1
npm install hexo-math --save

修改hexo-theme-next配置文件启动mathjax

在需要渲染公式界面添加配置mathjax: true

配置

  1. 创建标签云页

先创建tag页面,然后在主题_config.yml的Menu中配置

1
hexo new page tags
  1. 设置 DISQUS

注册DISQUS账户,创建网站[^4],修改主题配置文件,启动DISQUS

1
2
3
4
5
6
7
8
...
# Disqus
disqus:
enable: true
shortname: your-shortname
count: true
lazyload: false
...

参考

[^1]: Hexo 官方安装教程
[^2]: Hexo 修改渲染插件
[^3]: hexo-theme-next wiki
[^4]: DISQUS 创建网站