Github+Hexo搭建个人网站(一)
1.1 准备环境
1.1.1 下载Node.js
链接: https://nodejs.org/zh-cn/(下载LTS版)(Node.js的版本须大于6)
安装步骤基本傻瓜式安装,但安装模式需要点击一下

安装好之后,检测PATH环境变量是否配置了Node.js,输入cmd –> 输入path
可以观察到PATH中已经有C:\Program Files\nodejs\,如下图所示:

检查Node.js版本 输入 node –version可以看到我所下载的node.js版本为10.15.1

以上,node.js安装成功。
1.1.2 下载Git
步骤1:

步骤2:

步骤3:

步骤4:

1.1.3 下载Hexo
Git下载成功后,打开gitbash

步骤一:在任意盘新建文件夹来保存博客所有的内容。比如我是在D盘下新建文件夹github再在该文件夹中新建blog文件夹。
打开Gitbash进入我所创建好的文件夹,

也可一次性进入blog文件夹

步骤二:安装Hexo 在Gitbash命令行运行以下命令
npm install –g hexo-cli
如图:

步骤三:初始化Hexo在Gitbash命令行运行以下命令
hexo init

步骤四:查看blog文件下的文件在Gitbash命令行运行以下命令
dir
如图:

步骤五:在Gitbash命令行运行以下命令
hexo g

步骤六:再次输入dir 可查看到多出了一个public文件

步骤七:开启服务器在Gitbash命令行运行以下命令
hexo s

Ctrl +c 会停止若按了停止,则需要hexo s重新加载
在网址中打开http://localhost:4000则就可以看到

1.2 将Hexo与Github page联系起来
1.创建Github账号
2.创建仓库,仓库名为:<Github账号名称>.github.io
3.将本地Hexo博客推送到Github page上
3.1安装hexo-deployer-git插件。在Gitbash上输入以下命令
npm install hexo-deployer-git –save

3.2添加SSH key
3.2.1创建一个SSH key。在Gitbash上输入以下命令,回车三下:
$ ssh-keygen -t rsa -C "邮箱地址"
3.2.2 复制密钥文件内容(路径形如C:\Users\Administrator\.ssh\id_rsa.pub),粘贴到New SSH Key即可。如图

3.2.3 测试是否添加成功在Gitbash输入以下命令
$ ssh -Tgit@github.com
若输出以下内容,说明添加成功。

3.3修改_config.yml(站点目录下) 。文件末尾修改为:

# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type: git
repository: git@github.com: Github账号名称/Github账号名称.github.io.git
branch: master
例如我的是:

3.4推送到GithubPages 在Gitbash依此输入以下命令
$ hexo g
$ hexo d
3.5浏览器访问地址:https://<Github账号名称>.github.io
以上,Hexo博客已经搭建在Githubpage上了。