利用hexo在github上搭建博客

环境:nodejs
仓库:github
博客:hexo:https://hexo.io/zh-cn/
管理插件:hexo-admin:https://jaredforsyth.com/hexo-admin/

使用hexo在github上搭建一个简易的个人博客,本来想玩一下的,然后一下就搞出来了,,比想象中简单
根据指引安装node.js 安装hexo,安装git

部署在github上

1.先去github上创建一个仓库 [用户名].github.io,像这样


image.png

2.开始部署;先安装插件npm install hexo-deployer-git --save

3.在_config.yml里添加配置

deploy:
  type: git
  repository: https://{用户名}:{用户密码}@github.com/{用户名}/{用户名}.github.io.git
  branch: master

4.hexo generate提交代码修改

5.hexo deploy上传代码到github

6.然后就可以看到自己的博客了,像这样https://yhkevin93.github.io/

使用hexo-admin管理文章

几分钟就可以把博客搭建起来了,然后还需要一个管理插件来管理文章什么的,用的是hexo-admin

1.npm install --save hexo-admin

2.在_config.yml里添加配置

admin:
   username: name
   password_hash: $2a$10$zUljLuGYkEap8N4xa51peuGEVQHuZ1BaLIRay7Nn0zMVQDIDQlqzS
   secret: myblog
   deployCommand: './admin_script/hexo-generate.sh'

password要填哈希后的密码,直接写一个js代码,

 const bcrypt = require('bcrypt-nodejs')
 console.log(bcrypt.hashSync('your password'))

然后node test.js,就可以出现你密码的哈希填写到password_hash

3.然后回到自己的hexo目录输入 hexo server,进入http://localhost:4000/admin/就可以看到文章管理页面

4.修改完文章再重新提交到github

其他

1.好像hexo-admin只能本地使用,修改文章在提交到网站上去..不知道怎么在线修改..
2.其他博客还有一大堆功能没搞,以后再玩...

你可能感兴趣的:(利用hexo在github上搭建博客)