如何搭建hexo博客,并部署到GitHub上
2020-08-05 本文已影响0人
朴客
一、准备工作:
1.下载安装 Node.js(LTS)
2.安装 Git Bash

出现的问题:git下载太慢了;
解决方法:F12找到下载链接,利用迅雷下载;

安装教程可参考: 点击前往
二、安装hexo博客
1.全局安装hexo博客
win+r输入cmd
直接输入
npm install -g hexo-cli
检验是否安装成功输入hexo -v

出现如图,表示安装成功
2.生成hexo博客文件
接下来建立一个存放博客的文件夹;比如我放在d盘;建立一个bolg的文件夹
在bolg文件夹中,鼠标在空白处右击,打开git bash here

输入:hexo init
如图:

等待安装(路径一定要正确)
3.浏览器中预览
安装成功后输入hexo s

接着在浏览器中输入localhost:4000
就会出现如图所示:

在D:\blog\source_posts
路径下建立一个.md文件,就可以开始写你的博客了。
三、远程部署
远程部署可以部署到github,codeing……
这里是github:
1.首先在github建立一个仓库
注意:仓库名一定要是你github的名字<br />例如xxxx.github.io

必须是这样写(这里因为我已经建过了,出现重复了
2.安装插件
因为部署仓库需要插件<br />所以接着继续 在git上输入
npm install hexo-deployer-git --save
安装这个插件
3.改_config.yml文件
打开_config.yml文件

把最后几行进行更改
deploy:
type: git
repo: git仓库项目地址
branch: master
4.三行命令
hexo clean(清除缓存)
hexo g(上传到仓库)
hexo d(部署)

输入你github的账号和密码
上传成功!
5.在浏览器中输入你的仓库名,就可以看到你的博客啦~
四、添加ssh秘钥
添加ssh后,输过一次账号密码后,下次就不用输入了
1.在git输入
ssh-keygen -t rsa -C 你的邮箱.com

第一个是保存地址
第二个就是你github的密码,第三个是确认密码
2.生成ssh

接着打开github,打开设置点接添加秘钥
标题自己写
接着把id_rsa.pub代码复制到key上
这时你还收到关于这个的邮箱
下次部署不需要再输入账号密码,方便多了。