Hexo博客搭建与备份

搭建hexo博客

第一步:下载nodejs和git,官网下载,一路next即可。

第二步:配置git:

1
2
3
git config --global user.name "username" //到时候提交显示的用户名
git config --global user.email "username@email.com" //注册github的邮箱
git config --global --list //查看当前git帐号信息

第三步:生成ssh-key

1
2
3
ssh-keygen -t rsa
//一般生成的rsa秘钥会在:c:\user\xxx\.ssh id_rsa.pub 里面 将这里面的内容填到github中
ssh -T git@github.com //测试是ssh-key否配置正确

第四步:建立hexo博客文件

1
npm install -g hexo-cli --registry=https://registry.npm.taobao.org
1
hexo init myblog //初始化blog文件夹

如果提示无权限,请输入

1
set-ExecutionPolicy RemoteSigned

进入myblog文件夹后,使用该命令安装所需组件

1
npm install

以下是hexo博客的启动命令

1
2
hexo g
hexo server

第六步安装hexo部署

1
npm install hexo-deployer-git --save

安装完deployer之后,进入blog文件夹,修改config文件,滑到最底部修改成。(请注意,中间有空格),repo就是仓库的https地址。

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

申请github.io的地址

创建一个跟自己用户名一致的仓库即可,比如我是cdroad.github.io。