声明: 本文禁止转载,发布地址为我的 个人博客 和 知乎专栏,其它地方看到均为抄袭。
基本介绍
Hexo 是一款简单、快速、强大的 node.js 静态博客框架。
npm 是 node.js 的包管理工具,我们通过使用 npm 来安装 Hexo。
node.js 和 npm 安装这里不再赘述,网上有很多教程,提醒的是需要到官网下载新版的安装包,直接通过 apt-get 安装的版本太低。
npm 官方镜像一般连接速度太慢,我都是通过淘宝的 npm 镜像安装的,地址和使用方式如下。
https://npm.taobao.org/直接使用:npm install -g cnpm --registry=https://registry.npm.taobao.org
alias使用:
alias cnpm="npm --registry=https://registry.npm.taobao.org \
--cache=$HOME/.npm/.cache/cnpm \
--disturl=https://npm.taobao.org/dist \
--userconfig=$HOME/.cnpmrc"
# Or alias it in .bashrc or .zshrc
$ echo '\n#alias for cnpm\nalias cnpm="npm --registry=https://registry.npm.taobao.org \
--cache=$HOME/.npm/.cache/cnpm \
--disturl=https://npm.taobao.org/dist \
--userconfig=$HOME/.cnpmrc"' >> ~/.zshrc && source ~/.zshrc
Hexo安装,-g 全局安装
npm install hexo -g
博客创建
hexo init noogel
扩展插件安装
sudo npm install hexo-server --save --registry=https://registry.npm.taobao.org
sudo npm install hexo-admin --save --registry=https://registry.npm.taobao.org
sudo npm install hexo-generator-archive --save --registry=https://registry.npm.taobao.org
sudo npm install hexo-generator-feed --save --registry=https://registry.npm.taobao.org
sudo npm install hexo-generator-search --save --registry=https://registry.npm.taobao.org
sudo npm install hexo-generator-tag --save --registry=https://registry.npm.taobao.org
sudo npm install hexo-deployer-git --save --registry=https://registry.npm.taobao.org
sudo npm install hexo-generator-sitemap --save --registry=https://registry.npm.taobao.org
之后新的机器部署环境可以直接
sudo npm install --registry=https://registry.npm.taobao.org
会自动读取 package.json 文件进行安装
Hexo服务启动
有如下两种命令
hexo serve
hexo s -g
一键发布到 git
修改 _config.yml 配置
## Docs: https://hexo.io/docs/deployment.html
deploy:
# 类型
type: git
# 仓库
repo: git@github.com:noogel/noogel.github.io.git
# 分支
branch: master
发布命令
hexo d -g
清除发布结果
hexo clean
组合命令:alias hexod="hexo d -g && hexo clean"
添加tags
执行 hexo new page "tags",然后编辑 source/tags/index.md
配置修改
博客配置修改 _config.yml,主题配置修改 themes/<themes>/_config.yml
Hexo自动提交命令
这里设置了一个自动提交的命令,源码自动提交到 sources 分支
alias hexodp="hexo d -g && git add --all && git commit -am 'auto commit' && git push origin sources"
hexo-admin 管理文章
安装
npm install --save hexo-admin --registry=https://registry.npm.taobao.org
打开 http://localhost:4000/admin/
然后可以在里面配置登录账号密码,并添加到 _config.yml 文件中
# hexo-admin authentification
admin:
username: noogel
password_hash: $2a$10$CMR/GX.e6TuoGGOYOF7ks.R.WmSUC8RvelPPXIH5wV3S6hPLYPnx6
secret: a33x8sd83ndfus82jrfi8sj28djk438ds
预览界面如下:
Hexo常见问题解决办法
https://hexo.io/docs/troubleshooting.htmlhexo 先介绍到这里,我的个人博客地址 Noogle's notes ,欢迎大家到评论区进行交流~~