官方文档
1. 什么是 Hexo?
Hexo 是一个快速、简洁且高效的博客框架
2.安装Git Bash
下载地址:Git Bash。
安装步骤:双击exe,选择安装路径,一路next。
安装好后,在文件夹中右键能够看到图标就说明安装成功了,
打开git bash,查看版本:
命令:
git version
3. 安装Nodejs
步骤
安装完毕后查看版本:
命令:
node -v
同时安装npm,可查看版本
npm -v
4. 安装淘宝镜像
npm install -g cnpm --registry=https://registry.npm.taobao.org
查看
cnpm
5. 安装hexo-cli
cnpm install -g hexo-cli
6. 初始化项目
cd desktop
mkdir blog
cd blog
hexo init
cnpm install --save hexo-deployer-git
7. 配置_config.yml
type: git
repo: (这里使用自己的GitHub博客仓库链接)
branch: master
8. 推送到远程仓库
可先在本地查看效果
//重新生成
hexo g
//Start开启本地服务器,可访问
hexo s
打开本地网址
http://localhost:4000/
hexo d
打开网址
https://hcq29.github.io
9. 换主题
git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia
更改配置文件 将_config.yml中的theme:landscape改为theme:yilia
//清理一下
hexo clean
//重新生成
hexo g
Start
hexo s
10. 添加搜索功能
(1) 配置文件
注意每段前无空格
1、配置文件内找空白处粘贴文件
2、第一行jsonContent: 即下图96行前没有空格
97、98、99行前有一个空格
剩下的有两个空格
(2)然后运行
npm i hexo-generator-json-content --save
(3)设置图片
存放位置
头像/图标图片的存放位置是/themes/yilia/source/下任意位置,可以自己新建一个文件夹存放,我存放在assets文件夹下。
配置设置
配置文件为/themes/yilia/_config.yml。设置头像为配置文件中avatar一项,设置图标为配置文件中favicon一项,设置路径的根目录为/themes/yilia/source/。例如,我的头像存放的地址是/themes/yilia/source/assets/me.png,设置则为avatar: /assets/me.png。(图标同理)
$ hexo d
//发上错误 ERROR Deployer not found: git
npm install --save hexo-deployer-git
即可。
11. 新建文章
//新建文章
hexo new post page1 //这里的page1是新建文章的链接名称
//新建草稿
hexo new draft page2 //存储的是草稿page2
//发布草稿
hexo publish page2