相关链接
- Hexo官网文档:https://hexo.io/zh-cn/docs/
- Git官网:https://www.git-scm.com/
- Pro Git:https://www.git-scm.com/book/zh/v2
环境安装
项目 | 版本 | |
---|---|---|
操作系统 | Windows | |
Git | Git-2.20.1-x64 | https://www.git-scm.com |
Node.js | node-v11.6.0-x64 | https://nodejs.org |
Hexo | v3.8.0 | https://hexo.io |
Nexo | v6.7.0 | https://theme-next.org |
- 安装Git
下载地址:https://pan.baidu.com/s/1zqsvaxXrnF_AYY4iYkcgVw - 安装Node.js
下载地址:https://nodejs.org/dist/v11.6.0/node-v11.6.0-x64.msi - 安装 Hexo
使用 npm 安装 Hexo。1
npm install -g hexo-cli
安装完成后,在Windows系统的cmd命令窗口可以正常执行hexo命令,但是在Git Bash命令窗口执行hexo命令时,提示错误。
1 | ERROR Local hexo not found in C:\tecchen |
只好在当前目录执行npm install hexo –save,安装到项目目录中。
1 | npm install hexo --save |
建站
初始化,可以不指定目录,则在当前目录完成初始化。
1 | hexo init <folder> |
安装服务器
Hexo 3.0 把服务器独立成了个别模块,您必须先安装 hexo-server 才能使用。
1 | npm install hexo-server --save |
使用浏览器,访问http://localhost:4000 即可看到默认的主页。
切换主题
进入hexo根目录,执行以下命令该命令会创建themes/next目录,并clone Next主题。
1 | git clone https://github.com/theme-next/hexo-theme-next themes/next |
与所有 Hexo主题启用的模式一样。当克隆/下载完成后,打开站点配置文件,找到theme字段,并将其值更改为next。
1 | theme: next |
修改语言
修改站点配置文件,将language设置为zh-CN,将博客设置为中文。
1 | language: zh-CN |
重启服务器,并访问http://localhost:4000 即可看到Next主题下的Hexo主页。
hexo的其他命令
1 | hexo clean # 清理缓存文件 (db.json) 和已生成的静态文件 (public) |