快速搭建个人博客 Hexo && Gitee

Quick Start

1.安装Nodejs 和Git

1
2
3
4
5
http://nodejs.cn/download/  #node下载地址
node -v #查看node版本
npm -v #查看npm版本
https://git-scm.com/downloads #Git下载地址
git --version #查看Git版本

2.安装淘宝的cnpm包管理器

1
2
npm install -g cnpm --registry=http://registry.npm.taobao.org #安装淘宝的cnpm包管理器
cnpm -v #查看cnpm版本

3.安装Hexo框架

1
2
3
4
5
6
7
8
9
10
11
12
13
14
cnpm install -g hexo-cli  #安装Hexo框架  
hexo -v #查看hexo版本
mkdir blog #创建blog目录
cd blog #进入blog目录
sudo hexo init #生成博客 初始化博客
hexo s #启动本地博客服务
http://localhost:4000/ #本地访问地址

hexo n "我的第一篇文章" #创建新的文章
#返回blog目录
hexo clean #清理
hexo g #生成
hexo s #启动本地博客服务
http://localhost:4000/ #本地访问地址

4.修改主题

1
2
3
4
5
6
git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia  #下载yilia主题到本地
#修改hexo根目录下的 _config.yml 文件 : theme: yilia
hexo clean #清理一下
hexo g #生成
hexo s #启动本地博客服务
http://localhost:4000/ #本地访问地址

5.部署到Gitee

4.1 在Gitee新建一个名为个人用户名的仓库,在服务选项中开启Gitee Pages服务

配置blog根目录config.yml文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# URL
## If your site is put in a subdirectory, set url as 'http://example.com/child' and root as '/child/'
# url: http://example.com
url: https://YourGiteebName.gitee.io
root: /
permalink: :year/:month/:day/:title/
permalink_defaults:
pretty_urls:
trailing_index: true # Set to false to remove trailing 'index.html' from permalinks
trailing_html: true # Set to false to remove trailing '.html' from permalinks


# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type: git
repo: https://gitee.com/YourGiteebName/YourGiteebName.git
branch: master

4.2 推送到Gitee

1
2
3
4
cnpm install --save hexo-deployer-git #在Blog根目录下安装git部署插件
hexo clean #清理一下
hexo g #生成
hexo d #推送到Gitee

4.3 在仓库的服务选项中–Gitee Pages 服务 点击更新

点击 https://YourGiteebName.gitee.io 查看效果

其他插件

1
npm install hexo-abbrlink --save  #链接转换插件