github博客搭建
十一月 20, 2019
本文主要解决如何在github上搭建hexo博客。主要涉及到两部分内容:
- 搭建博客流程及相关工具
- 书写博客流程及相关方法
github博客搭建
- 注册github账号,网址https://github.com
- 创建博客仓库,仓库名称必须为username.github.io,这里的username为你的用户名,将来博客访问地址https://username.github.io
- 配置本机ssh免密访问github将用户家目录下的.ssh/id_rsa.pub文件内容复制到github中个人设置–>SSH and GPG keys–>New SSH key
1
ssh-keygen -t rsa
测试方法如下则表示配成功1
2$ ssh -T git@github.com
You've successfully authenticated, but GitHub does not provide shell access. - 配置git全局信息
1
2$ git config --global user.name "username"// 你的github用户名,非昵称
$ git config --global user.email "user@qq.com"// 填写你的github注册邮箱
hexo博客书写
- 本地安装nodejs,npm
- 安装hexo
1
2
3npm install -g hexo
#hexo部署github插件
npm install hexo-deployer-git --save - 初始化博客
1
2
3
4
5
6#初始化博客
hexo init
#生成文件
hexo g
#启动服务器
hexo s - 上传博客到github
修改_config.yml文件1
2
3
4deploy:
type: git
repo: git@github.com:usrname/usrname.github.io.git
branch: master - 写文章
1
2
3
4
5
6#创建文章
hexo new postname
#生成文章
hexo clean
#上传文章
hexo d -g - 更换主题
下载hexo主题,修改_config.yml文件
查看评论