Github+Hexo搭配个人博客

Github+Hexo+node.js+git搭配个人博客

node安装hexo

全局安装hexo脚手架

1
cnpm install hexo-cli -g

hexo初始化项目文件夹

1
hexo init hexoBlog

进入文件夹,安装依赖

1
2
cd hexoBlog
cnpm install

本地浏览http://localhost:4000/

1
2
hexo server
hexo s

github部分

新建仓库,仓库名称和用户名一样,并认证邮箱

1
2
3
4
new repository
用户名: pengrongjie
仓库名: pengrongjie.github.io

git部分

配置github ssh-keygen

在hexoBlog,右键Git Bash here,输入邮箱名字

1
输入 ssh-keygen -t rsa -C "352938347@email.com"

提醒你输入key的名称,你可以不用输入,直接3个回车,就OK了;
在C:Documents and SettingsAdministrator下产生两个文件:id_rsa和id_rsa.pub
用记事本打开id_rsa.pub文件,复制内容,在github的网站上找到ssh密钥管理页面,添加新公钥 。
在git bash中输入ssh -T git@github.com命令,出现Hi sylujia! You’ve successfully authenticated表示成功。

本地注册

1
2
git config --global user.name "pengrongjie"//用户名
git config --global user.email "352938347@qq.com"//填写自己的邮箱

回到hexo

安装next主题

1
git clone https://github.com/iissnan/hexo-theme-next themes/next

修改外部_comfig.yml

1
theme: next

把本地的博客内容同步到 Github 上

安装依赖

1
cnpm install hexo-deployer-git --save

配置外部_comfig.yml

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