Fei Blog

github pages 和 hexo 配置个人博客

2017/11/07
阅读量:

之前在CSDN上写博客,今天心血来潮,决定自己搭个博客。采用github pages 和 hexo,
现在把搭建过程和遇到的问题整理一下~

新建git仓库

这个过程很简单,在github上新建名字为 用户名.github.io 的仓库

安装hexo

1
npm install -g hexo-cli

采用npm进行安装,安装过程报错,Permission denied
加了sudo

1
sudo npm install -g hexo-cli

报错,cannot create highlight_alias.json: Permission denied
运行命令

1
npm config set unsafe-perm true

之后再安装

1
sudo npm install -g hexo-cli

成功

配置hexo

初始化

1
2
3
hexo init Code/Blog
cd Code/Blog
npm install

修改配置文件_config.yml

1
2
3
4
deploy:
type: git
repo: https://github.com/lifeilu/lifeilu.github.io.git
branch: master

本地测试

1
2
3
hexo clean
hexo generate
hexo server

可以本地在localhost里打开预览

部署hexo到github

安装hexo-deployer-git

1
npm install hexo-deployer-git --save

这样才能将你写好的文章部署到github服务器上并让别人浏览到。之后运行

1
2
3
hexo clean
hexo generate
hexo deploy

以上就完成了博客的搭建。可以自己定义主题写博客咯~开心

常见命令

新建页面

1
hexo new [layout] <title>

参考网址
1.http://blog.csdn.net/wlmnzf/article/details/73660441
2.https://docs.npmjs.com/getting-started/fixing-npm-permissions

CATALOG
  1. 1. 新建git仓库
  2. 2. 安装hexo
  3. 3. 配置hexo
    1. 3.1. 初始化
    2. 3.2. 修改配置文件_config.yml
    3. 3.3. 本地测试
  4. 4. 部署hexo到github
  5. 5. 常见命令
    1. 5.1. 新建页面