从0开始搭建自己的个人博客hexo(二)
上一篇我们介绍了在本地搭建一个服务器并且成功运行测试,这次我们把它部署到Github,让别人也可以访问我们的网站。
1.将博客部署到github
-
首先登录github账号,没有的请注册一个。
-
创建一个repository,名称为yourname.github.io, 其中yourname是你的github名称,按照这个规则创建才有用。
-
在本地文件下安装部署插件
cnpm install --save hexo-deployer-git
-
根目录下面的_config.yml叫做站点配置文件
-
而进入themes–>主题–>_config.yml的文件叫做主题配置文件
2.修改_config.yml
用编辑器打开你的blog项目,修改_config.yml文件的一些配置(冒号之后都是有一个半角空格的):
deploy:
type: git
repo: https://github.com/Fmk1998/Fmk1998.github.io.git
branch: master
3.部署到远端
-
hexo d
-
输入github的用户名和密码
-
刷新github仓库
发现多了很多东西 -
直接访问部署的地址
我的博客
https://fmk1998.github.io/
记住,当你出现错误啥的情况下先执行下面三步: -
hexo clean
-
hexo g
-
hexo s
4.更换博客主题
-
下载主题
在blog文件夹下命令行运行 git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia
- 修改_config.yml
theme: yilia
- hexo clean
- hexo g
- hexo s