0%

hello hexo

第一篇博客,先学学hexo吧。。

安装就不说了。存一下常用命令(摘自知乎专栏

1
2
3
4
5
6
7
8
hexo new "name"       # 新建文章
hexo new page "name" # 新建页面
hexo g # 生成页面
hexo d # 部署
hexo g -d # 生成页面并部署
hexo s # 本地预览
hexo clean # 清除缓存和已生成的静态文件
hexo help # 帮助

第一件事当然是换主题,先试试第一名的NexT

1
git clone https://github.com/theme-next/hexo-theme-next themes/next

NexT官方项目里推荐了下面几个plugins,不管用不用的上先全装了

最后是一些配置

中文

NexT官网说的zh-Hans不一样

1
language: zh-CN

Github配置

要装上hexo-deployer-git,然后修改_config.yml

Github page有两种模式,一种是建username.github.io的repo,然后部署到master分支

1
2
3
4
deploy:
type: git
repository: git@github.com:ekibun/ekibun.github.io.git
branch: master

还有一种是发布到repo的gh-pages分支:

1
2
3
4
deploy:
type: git
repository: git@github.com:ekibun/ekibook.git
branch: gh-pages

保存本地图片

要装上hexo-asset-image,然后修改_config.yml

1
post_asset_folder: true

使用上有两种,一个是建立和页面一样的文件夹,然后用相对路径page/image.jpg

另一个是放在source/images里面然后用绝对路径/images/image.jpg

图标CDN

NexT默认用的字体要从FontAwesome下载,然后把fonts文件夹放到source文件夹下面图标才会正常显示

加上fonts文件夹之后加载会非常慢,不知道为什么原来的cdn死活加不上,换成稳定版的NexT之后就行了。把主题的lib库删了,全换成cdn:

1
fontawesome: //cdn.jsdelivr.net/npm/font-awesome@4/css/font-awesome.min.css

TAG页面

hexo new page tags创建一个页面,然后index.md加上type: "tags"

1
2
3
4
5
6
---
title: tags
date: 2020-03-15 20:43:21
type: "tags"
comments: false
---

Gitalk评论

先在Github创建一个OAuth App,然后在NexT里的_config.yml把数据填上

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Gitalk
# For more information: https://gitalk.github.io, https://github.com/gitalk/gitalk
gitalk:
enable: true
github_id: ekibun # GitHub repo owner
repo: ekibun.github.io # Repository name to store issues
client_id: *** # GitHub Application Client ID
client_secret: ***** # GitHub Application Client Secret
admin_user: ekibun # GitHub repo owner and collaborators, only these guys can initialize gitHub issues
distraction_free_mode: true # Facebook-like distraction free mode
# Gitalk's display language depends on user's browser or system environment
# If you want everyone visiting your site to see a uniform language, you can set a force language value
# Available values: en | es-ES | fr | ru | zh-CN | zh-TW
language: zh-CN

访客统计

NexT配置文件里把busuanzi_count打开就行了

1
2
3
4
# Show Views / Visitors of the website / page with busuanzi.
# Get more information on http://ibruce.info/2015/04/04/busuanzi
busuanzi_count:
enable: true

字数统计

装上插件hexo-symbols-count-time直接生效

站点地图

需要hexo-generator-sitemaphexo-generator-baidu-sitemap,但是我没感觉它们生成的东西有什么不同,另外,hexo-generator-baidu-sitemaproot不是根目录的支持不好,需要重新指定url:

1
2
baidusitemap:
url: https://ekibun.github.io