4.程序员装逼指南之Blog

GitHub Pages

GitHub Pages

hexo

教程

以下几点特别说明一下

使用hexo deploy发布

1
2
3
4
5
6
# _config.yml
deploy:
type: git
repo: https://github.com/ZiFy/ZiFy.github.io.git
branch: master
message: "hexo自动发布"

特别提醒:
这个命令会把你的文件都删了,只保留发布的文件。
所以,请一定要选择另一个分支开发,这样才能把markdown文件保留下来。

1
2
3
4
一键发布测试
$ hexo g&&hexo s
一键发布命令
$ hexo g&&hexo d

使用CI自动发布

markdown支持本地图片

使用hexo-asset-image

Next

next 是一款了不起的hexo主题,支持很多功能。最重要是风格适合程序员。 [你是我的眼,眼里只有黑白色]

hexo-theme-next

hexo-theme-next-github

可以添加的功能

Next第三方服务集成

评论 Gitalk

github OAuth Apps

Annie主题使用Gitalk

1
2
3
4
5
6
7
8
9
# /theme/next/_config.yml
gitalk:
enable: true
github_id: Zify # Github repo owner
repo: blog_comment_repo # Repository name to store issues.
client_id: c30a8xxxx # Github Application Client ID
client_secret: 916ce8fxx # Github Application Client Secret
admin_user: Zify # GitHub repo owner and collaborators, only these guys can initialize github issues
distraction_free_mode: true # Facebook-like distraction free mode
未找到相关的 Issues 进行评论

使用自己的账号登录一下,打开页面就会自动初始化。
gitalk-comment

Baidu analytics

https://tongji.baidu.com/

google analytics

https://analytics.google.com/

使用busuanzi统计阅读次数

1
2
3
4
5
6
7
8
busuanzi_count:
enable: true
total_visitors: true
total_visitors_icon: user
total_views: true
total_views_icon: eye
post_views: true
post_views_icon: eye

RSS

1
$ npm install --save hexo-generator-feed

next配置RSS

标签页面,分类页面

hexo 创建文章、标签、分类

页面-阅读排行

hexo page 阅读排行

next自定义样式

hexo-theme-next主题设置

Hexo-NexT配置超炫网页效果

hexo-admin发布平台

(不重要,hexo3.8, hexo-admin2.3.0下存在bug)

hexo-admin

那个人的hexo-admin教程

1
2
3
npm install --save hexo-admin
hexo server -d
open http://localhost:4000/admin/

SEO优化

Hexo博客Next主题SEO优化方法

Hexo博客压缩优化

Hexo博客生成的静态文件存在大量空白,不仅难看,而且在一定程度上影响用户网页加载,需要对js和css进行压缩。

安装插件

1
$ npm install hexo-neat --save

配置

在站点配置增加如下属性,可以选择是否压缩HTML、CSS、Js文件,均有相应的开关选项。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# hexo-neat

neat_enable: true

neat_html:
enable: true
exclude:

neat_css:
enable: true
exclude:
- '*.min.css'

neat_js:
enable: true
mangle: true
output:
compress:
exclude:
- '*.min.js'
0%