博客搭建历程(2)


一、使用hexo deploy部署博客到Github

使用参考

** 先安装个扩展$ npm install hexo-deployer-git --save **

1.修改博客根目录下的_config_yml文件

# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
  type: git
  repo: git@github.com:yeshan333/yeshan333.github.io.git # 这个可到Github仓库拿
  branch: master

2.部署到GitHub repo

生成ssh keys

ssh-keygen -t rsa -C "邮件地址@youremail.com" #生成新的key文件,邮箱地址填注册Github时用的

https://img.vim-cn.com/37/ecb8a0a1f900c804d06651139773f0979a6270.png

将生成的ssh keys添加到Github的deploy keys中

    1. 复制key

** 这里用到.ssh目录下,id_rsa.pub文件中的那串key**

https://img.vim-cn.com/5b/a4d58b99d58d1c22ffec0e5fc6301c45b20b58.png

    1. 到GitHub的yourname.hithub.io仓库添加那串key到deploy keys中

    1. 测试一下是否添加成功了:
ssh -T git@github.com

部署博客

  1. 先配好git用户信息
git config --global user.name "你的名字"     # github用户名
git config --global user.email "邮箱@邮箱.com"    # github邮箱
  1. 部署博客到仓库
hexo g # 生成静态文件
hexo d # 部署到远程仓库

访问https://yourname.github.io查看结果

** 到此,整个博客搭建完成了 **

以下是写的是博客主题的更换,主题可以自己写,也可以使用别人写的,可去这里https://hexo.io/themes/找喜欢的主题,如果使用的是别人的主题,需要阅读主题使用文档进行相关配置。

二、Hexo主题设置

    1. 更换主题

cd进themes目录

cd themes
git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia
    1. 对根目录下的config_yml文件进行修改
cd themes/yilia
git pull #更新主题

    1. 预览新主题
hexo clean # 清楚缓存,删除public目录
hexo g     # 生成新的博客静态文件
hexo s

http://localhost:4000预览,没毛病就hexo d部署到远程仓库。


文章作者: ShanSan
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 ShanSan !
 上一篇
xuxu xuxu
baidu收录测试
2018-09-26 ShanSan
下一篇 
博客搭建历程(1) 博客搭建历程(1)
我为什么要搭建自己的博客:人嘛!总会有迷茫的时候。无聊了就搭建一个博客玩玩。借此思考下人生戳这里先洗下脑 [BetterExplained]为什么你应该(从现在开始就)写博客 使用Hexo+GitHub Pages搭建属于自己的博客依赖
2018-09-25
  目录