环境准备
1. install nvm
1
2
3
4
5
6
| # refrence (https://hackernoon.com/how-to-install-node-js-on-ubuntu-16-04-18-04-using-nvm-node-version-manager-668a7166b854)
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
bash install_nvm.sh
source ~/.profile
nvm --version
nvm ls-remote
|
2. install nodejs
1
2
3
4
| nvm install 10.15
nvm use 10.15
node -v
npm -v
|
3. install+set yarn
1
2
3
4
| npm i -g npm --registry https://registry.npm.taobao.org
npm i -g yarn --registry https://registry.npm.taobao.org
# set yarn use taobao proxy
yarn config set registry https://registry.npm.taobao.org
|
4. install hexo
1
2
3
4
5
6
7
| # install pkg
yarn install
# 安装包
npm install hexo-generator-searchdb --save
npm install -g hexo-cli
npm install -g hexo@3.9.0
|
使用说明
1. 本地调试
1
2
3
4
5
6
7
| # local start
hexo g
## 启动服务
hexo s
## 清理
hexo clean
|
2. 创建博客
1
2
3
4
5
6
7
8
9
10
11
12
| # 创建博客(TITLE 不能带空格,不能加特殊字符)
hexo new devops --path devops/ TITLE
# 创建草稿
hexo new draft hexo常用命令备忘录
# 本机预览草稿
hexo S --draft
# 将草稿发布为正式文章
hexo P hexo常用命令备忘录
# 或者 将草稿 以 bash 的布局发布(不支持--path参数知道目录,文件会保存在_post目录下,只能手动移动到相应子文件夹下)
hexo publish bash hexo常用命令备忘录
|
配置文件
常见配置
1. 放图片或文件下载
- 本网站挂载
hexo在构建成静态页面时,会将目录./source/images/
下的内容全部拷贝至./public/images/
目录。而public
目录为网站根目录。
所以需要以下操作:
- 将文件或照片放至
./source/images/
目录下 - 在md文件中,图片通过
![例子](/images/<相对source/images目录的路径>)
或<img src="/images/<相对source/images目录的路径>" width="80%">
文件通过[例子-文件](/images/<相对source/images目录的路径>)
hexo构建后的静态网页会将source目录下的文件夹(除_data/
, _drafts
, posts
)放至 根目录下,所以可以通过绝对路径索引。
- 使用chrome插件
微博图床
工具上传图片 - 将url放至md文件中例如
![xxx图片](https://hex-cdn.oss-cn-hangzhou.aliyuncs.com/old/yNuAgl.jpg)
遗留问题
计划迁移 hugo, 遗留以下问题 暂不处理
local-search设置
CDN加速
国内字体
参考
Hexo生成Post: post、page、draft
Hexo文章保存为草稿
Hexo+Github博客搭建小白教程