每次编辑文章都要本地写好md文件或者在服务器上编辑md,麻烦的很,于是我在想有没有什么办法可以在线编辑呢,找了一圈找到了hexo-admin 等于是hexo的后台管理。

安装hexo-admin插件

npm install --save hexo-admin

访问admin管理界面

启动后访问原来hexo博客的地址后加个/admin 就可以进入了。
hexo server -d

配置登录密码

自己的管理后台总不能让人随便访问吧
进来以后点击settings

然后在hexo的最外层 _config.yml配置文件中添加settings提供的配置即可

1
2
3
4
admin:
username: myfavoritename
password_hash: be121740bf988b2225a313fa1f107ca1
secret: a secret something

重启后,就会提示用户名密码登录了

发布文章

进入后台之后点击Deploy,里面的Deploy按钮是用来执行发布脚本的,所以我们先在博客根目录下新建个目录admin_script,然后在目录中新建一个脚本hexo-d.sh,里面写下下面代码然后保存

1
2
3
#!/usr/bin/env sh
hexo clean
hexo g -d

记得赋予执行权限
chmod +x hexo-d.sh

然后在配置文件中添加

1
2
3
4
5
admin:
username: myfavoritename
password_hash: be121740bf988b2225a313fa1f107ca1
secret: a secret something
deployCommand: ./admin_script/hexo-d.sh