Hexo 搭建个人博客
此教程基本为当前blog的搭建过程,其中遇到的主要问题记录在下面,未来不定期更新。
1. 按照 Next 主题的步骤搭建
首先安装hexo官网教程安装hexo
https://hexo.io/docs/
然后将Next主题安装在theme文件夹内
https://github.com/iissnan/hexo-theme-next
2. 更换主题scheme
,在theme/next/_config
中更换scheme
。
1 | # Schemes |
3. 新建文章
1 | hexo new post "title" |
4. 安装hexo-wordcount来显示每篇文章的字数,阅读时间等等
https://github.com/willin/hexo-wordcount
5. 更换markdown渲染工具,适配mathjax
1 | npm uninstall hexo-renderer-marked --save |
6. 上传头像
将头像文件放置在/source/uploads/avatar.gif
在主题_config
文件中找到avatar:
填上上述地址
7. 部署git
首先在github上建立一个repo,其名称为yourname.github.io,注意这里yourname需要跟你的github的用户名一致。然后在hexo的_config填写配置
1 | deploy: |
然后用hexo生成静态网页,最后提交
1 | hexo clean |
8. 建立sitemap
安装sitemap生成工具
1 | npm install hexo-generator-sitemap --save |
然后在_config.yml中填写配置
1 | # sitemap |
最后用hexo生成,部署即可。
9. 增加文章分享功能
编辑主题配置文件,添加/修改字段jiathis
,值为true
1 | # JiaThis 分享服务 |
10. 阅读次数统计( LeanCloud )
- LeanCloud 注册帐号
- 创建应用,名称自拟
- 创建
Class
,名称为Counter
,选择无限制ACL权限 - 设置-应用Key,复制
App ID
和App Key
到主题配置文件
1 | leancloud_visitors: |
11. 文章内anchor跳转
markdown语法中可以通过[link](#tile name)
来跳转到特定的段落标题上,例如:
1 | [link](#tile name) |
但是在hexo中md转换为html后标题中的空格会转换为-
因此上述连接需修改为[link](#tile-name)