





介绍Hexo博客的搭建以及部署到GitHub上
框架安装
-
官网安装Node.js
-
利用cnmp解决npm下载安装缓慢问题
1
npm install -g cnpm --registry=https://registry.npm.taobao.org
在安装之前需要安装Git
-
安装Hexo框架
cnpm install -g hexo-cli
框架配置
- 切换到新建博客目录下
hexo init自动生成框架hexo s启动检验Hexo3将server独立需单独安装
命令npm install hexo-server --save
如果EADDRINUSE错误修改端口例如hexo s -p 8080
框架目录
1 | . |
_config.yml
修改配置信息
package.json
应用程序的信息
scaffolds
模版文件夹
source
资源文件夹是存放用户资源的地方
除_posts文件夹之外,开头命名为_(下划线)的文件 / 文件夹和隐藏的文件将会被忽略。Markdown 和 HTML 文件会被解析并放到 public文件夹,而其他文件会被拷贝过去。
themes
主题文件夹
博客使用
-
hexo n "title"创建文章按照scaffolds文件夹模板创建
此外可以创建草稿hexo new draft "title" -
hexo clean -
hexo g生成博客
远端部署
-
安装GitHub插件
cnpm install -g hexo-deployer-git --save -
在Github上创建项目库
项目库命名要是 用户名+.github.io 例如:lanqilu.github.io
-
设置 _config.yml 文件
1
2
3
4
5
6# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type: git
repo: https://github.com/<GitHub_name>/<GitHub_repositories>.git
branch: master -
部署到远端
hexo d
填写github账号密码 -
常用部署命令
cmdhexo clean && hexo g && hexo d
powershellhexo clean '&' hexo g '&' hexo d
更换主题
以Next为例
-
克隆到themes目录下
1
git clone https://github.com/theme-next/hexo-theme-next.git
-
配置
_config.yml1
2
3
4# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: next-reloaded # 主题名
问题
图片问题
配置_config.yml里面的post_asset_folder:false这个选项设置为true
默认在创建新文件时生成同名文件夹
使用方法

推荐使用图床来在Markdown文本中插入图片
