使用Github建个人博客
步骤:
本地电脑安装
安装Node
1
brew install node
安装yarn
-
1
brew install yarn
安装hexo
1
yarn global add hexo
新建一个Blog项目
1
hexo init blog
启动本地Hexo服务,查看测试页面
1
2cd blog
hexo server本机测试页面:
网站修改
- 安装Next主题(或其它主题)
1 | cd blog #blog为网站所在文件夹,可自定义或通过finder修改 |
修改根文件夹下的_config.yml文件,theme指向next
1
theme: next
hexo server启动服务查看测试页面。
1
hexo server
配置主题,以及网站_config.yml
相关命令
1 | hexo new page "about" #生成about网页 |
关联Github
新建一个Reposity ,名字
.github.io 根目录下_config.yml填写Reposity信息
1
2
3
4deploy:
type: git
repo: https://github.com/yjf2614/yjf2614.github.io.git
branch: masterdeploy
1
hexo d
弹出填写用户名密码(github帐号)
username:
password: 密码不是登陆密码,在github setting上找personal access token
deploy完成后,使用
.github.io访问网站。
其它
增加阅读人数统计功能
注册leancloud国际版
创建应用
创建class
转到应用凭证界面
修改theme文件夹下的_config.yml文件
1
2
3
4leancloud_visitors:
enable: true
app_id: <your-id>
app_key: <your-key>
换系统或者换电脑需要重装 hexo
的时候,只需要在hexo
环境搭建好的基础上,只需要把 source
、themes
、 _config.yml
覆盖到新的博客目录下即可
参考文章:
https://yogapan.github.io/2017/08/11/用Hexo-Github-Pages搭建個人部落格/ #部分命令已过时
如何在 GitHub 上写博客? - 吴师兄学算法的回答 - 知乎
https://www.zhihu.com/question/20962496/answer/1882882782 #Next主题修改