Hexo博客框架安装教程
安装流程
-
安装nodejs
-
安装cnpm(可选)
npm install cnpm -g --registry=https://registry.npm.taobao.org
- 安装hexo-cli
cnpm install -g hexo-cli
- 验证安装
hexo -v
- 初始化并启动
hexo init blog
cd blog
npm intall
hexo server(或者s)
- 写文章
hexo n “标题”
- 生成并预览
hexo clean
hexo g
hexo s
发布到github
- 安装hexo-deployer-git
cnpm install --save hexo-deployer-git
- 配置_config.yml
此处主要是与github做绑定,将本地修改的直接推送到github上。
注意:需要先在github上创建项目名为:用户名.github.io
deploy:
type: git
repo: https://github.com/用户名/项目名
branch: master
- 部署到github
hexo d
- 测试
在地址栏中输入项目名,直接进入博客
更换主题
自行搜索主题进行替换,此处演示yillia主题替换:
- 克隆主题
git clone https://www.github.com/litten/hexo-theme-yilia.git themes/yilia
- 替换
hexo clean && hexo d
再推荐两个主题:
git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia
https://github.com/nexmoe/hexo-theme-nexmoe (自用)
主题集合:
https://hexo.io/themes/
还有一个安卓风格主题:
cd themes
git clone https://github.com/viosey/hexo-theme-material.git material
cd material
git checkout {branch/tags name}
注意:如果有需要,把主题文件夹内的config文件名重命名一下!去掉templete
以上三个主题全部fork到了我的gitee仓库中,提升下载速度。主题安装方式和配置参考各自主题的文档
注意此处有坑:
如果采用Gitee托管的话,进入托管的仓库->设置Gitee Pages服务,若绑定域名需要升级Gitee Pro,普通版每次更新要进行手动更新!!!
具体参考:https://gitee.com/help/articles/4136
github 需要使用域名才能进行访问,我购买了xiaopi3.fun这个域名,需要在该项目的设置中的domain设置那里填入自己的域名,并启用https
hexo默认解析md有可能会有奇怪的bug,需要先本地预览看看自己调一下
hexo 归档有问题,与某个分页参数有影响,需要取消该参数:
# Pagination ## Set per_page to 0 to disable pagination per_page: 0 pagination_dir: page
实测不影响分页,同时归档显示不全问题解决
折叠文章使用:<!--more-->
当md文件中存在: {{ }}
or {% %}
将会被转义导致错误,使用下面的方式来处理:
由于无法正常显示,故只能这样显示出来{% raw %}Hello {{ sensitive }}{% endraw %}