天天看点

博客搭建历程(2)一、使用hexo deploy部署博客到Github二、Hexo主题设置

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

使用参考

** 先安装个扩展

$ npm install hexo-deployer-git --save

**

1.修改博客根目录下的

_config_yml

文件

博客搭建历程(2)一、使用hexo deploy部署博客到Github二、Hexo主题设置
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
  type: git
  repo: [email protected]:yeshan333/yeshan333.github.io.git # 这个可到Github仓库拿
  branch: master           

复制

博客搭建历程(2)一、使用hexo deploy部署博客到Github二、Hexo主题设置

2.部署到GitHub repo

生成ssh keys

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

复制

博客搭建历程(2)一、使用hexo deploy部署博客到Github二、Hexo主题设置

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

    1. 复制key

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

博客搭建历程(2)一、使用hexo deploy部署博客到Github二、Hexo主题设置
    1. 到GitHub的yourname.hithub.io仓库添加那串key到deploy keys中
博客搭建历程(2)一、使用hexo deploy部署博客到Github二、Hexo主题设置
    1. 测试一下是否添加成功了:
ssh -T [email protected]           

复制

博客搭建历程(2)一、使用hexo deploy部署博客到Github二、Hexo主题设置

部署博客

  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 #更新主题           

复制

博客搭建历程(2)一、使用hexo deploy部署博客到Github二、Hexo主题设置
    1. 预览新主题
hexo clean # 清楚缓存,删除public目录
hexo g     # 生成新的博客静态文件
hexo s           

复制

去http://localhost:4000预览,没毛病就

hexo d

部署到远程仓库。