Hexo 博客搭建记录
Ehoac Lv3

安装 node

使用 nvm 安装 Node

1
2
3
4
5
# 安装 node v14.15.4
nvm install 14.15.4

# 使用 node v14.15.4
nvm use 14.15.4

修改 nvm 使用镜像

1
2
3
# nvm安装目录中settings.txt中增加
nvm node_mirror https://npm.taobao.org/mirrors/node/
nvm npm_mirror https://npm.taobao.org/mirrors/npm/

安装 Hexo

1
npm install -g hexo-cli

建立博客

1
2
3
4
# 进入要放置博客的目录
hexo init <folder>
cd <folder>
npm install

Hexo 配置文件

_config.yml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/

# Site
title: Ehoac の Blog
subtitle: "日常记录"
description: "路漫漫其修远兮,吾将上下而求索。"
keywords:
author: ehoac
language:
- zh
- zh-CN
- en
timezone: "Asia/Shanghai"

# URL
## If your site is put in a subdirectory, set url as 'http://example.com/child' and root as '/child/'
url: http://XXX.com
root: /
permalink: :year-:month-:day/:hash.html
permalink_defaults:
pretty_urls:
trailing_index: true # Set to false to remove trailing 'index.html' from permalinks
trailing_html: true # Set to false to remove trailing '.html' from permalinks

# Directory
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:

# Writing
new_post_name: :title.md # File name of new posts
default_layout: post
titlecase: false # Transform title into titlecase
external_link:
enable: true # Open external links in new tab
field: site # Apply to the whole site
exclude: ""
filename_case: 0
render_drafts: false
post_asset_folder: false
relative_link: false
future: true
highlight:
enable: true
line_number: true
auto_detect: false
tab_replace: ""
wrap: true
hljs: false
prismjs:
enable: false
preprocess: true
line_number: true
tab_replace: ""

# Home page setting
# path: Root path for your blogs index page. (default = '')
# per_page: Posts displayed per page. (0 = disable pagination)
# order_by: Posts order. (Order by date descending by default)
index_generator:
path: ""
per_page: 10
order_by: -date

# Category & Tag
default_category: uncategorized
category_map:
tag_map:

# Metadata elements
## https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
meta_generator: true

# Date / Time format
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format: YYYY-MM-DD
time_format: HH:mm:ss
## updated_option supports 'mtime', 'date', 'empty'
updated_option: "mtime"

# Pagination
## Set per_page to 0 to disable pagination
per_page: 10
pagination_dir: page

# 主题
theme: icarus

# 部署到git服务
deploy:
type: "git"
repo: git@XXX.com:/path/to/server/blog.git
branch: master

Hexo 主题 hexo-theme-icarus

1
2
npm install hexo-theme-icarus
hexo config theme icarus

icarus 主题配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
# Version of the configuration file
version: 4.0.0
# Icarus theme variant, can be "default" or "cyberpunk"
variant: default
# Path or URL to the website's logo
logo: /img/logo.svg
# Page metadata configurations
head:
# URL or path to the website's icon
favicon: /img/favicon.svg
# Web application manifests configuration
# https://developer.mozilla.org/en-US/docs/Web/Manifest
manifest:
# Name of the web application (default to the site title)
name: Ehoac の Blog
# The displayed name of the web application
# when there is not enough space to display full name
short_name: Ehoac
# The start URL of the web application
start_url:
# The default theme color for the application
theme_color:
# A placeholder background color for the application page to display
# before its stylesheet is loaded
background_color:
# The preferred display mode for the website
display: standalone
# Image files that can serve as application icons for different contexts
icons:
- # The path to the image file
src: ""
# A string containing space-separated image dimensions
sizes: ""
# A hint as to the media type of the image
type:
# Open Graph metadata
# https://hexo.io/docs/helpers.html#open-graph
open_graph:
# Page title (og:title) (optional)
# You should leave this blank for most of the time
title:
# Page type (og:type) (optional)
# You should leave this blank for most of the time
type: blog
# Page URL (og:url) (optional)
# You should leave this blank for most of the time
url:
# Page cover (og:image) (optional)
# You should leave this blank for most of the time
image:
# Site name (og:site_name) (optional)
# You should leave this blank for most of the time
site_name:
# Page author (article:author) (optional)
# You should leave this blank for most of the time
author:
# Page description (og:description) (optional)
# You should leave this blank for most of the time
description:
# Twitter card type (twitter:card)
twitter_card:
# Twitter ID (twitter:creator)
twitter_id:
# Twitter Site (twitter:site)
twitter_site:
# Google+ profile link (deprecated)
google_plus:
# Facebook admin ID
fb_admins:
# Facebook App ID
fb_app_id:
# Structured data of the page
# https://developers.google.com/search/docs/guides/intro-structured-data
structured_data:
# Page title (optional)
# You should leave this blank for most of the time
title:
# Page description (optional)
# You should leave this blank for most of the time
description:
# Page URL (optional)
# You should leave this blank for most of the time
url:
# Page author (article:author) (optional)
# You should leave this blank for most of the time
author:
# Page images (optional)
# You should leave this blank for most of the time
image:
# Additional HTML meta tags in an array
meta:
# Meta tag specified in <attribute>=<value> style
# E.g., name=theme-color;content=#123456 => <meta name="theme-color" content="#123456">
- ""
# URL or path to the website's RSS atom.xml
rss:
# Page top navigation bar configurations
navbar:
# Navigation menu items
menu:
主页: /
归档: /archives
分类: /categories
标签: /tags
关于: /about
# Links to be shown on the right of the navigation bar
# links:
# Download on GitHub:
# icon: fab fa-github
# url: "https://github.com/ppoffice/hexo-theme-icarus"
# Page footer configurations
footer:
# Links to be shown on the right of the footer section
# links:
# Creative Commons:
# icon: fab fa-creative-commons
# url: "https://creativecommons.org/"
# Attribution 4.0 International:
# icon: fab fa-creative-commons-by
# url: "https://creativecommons.org/licenses/by/4.0/"
# Download on GitHub:
# icon: fab fa-github
# url: "https://github.com/ppoffice/hexo-theme-icarus"
# Article related configurations
article:
# Code highlight settings
highlight:
# Code highlight themes
# https://github.com/highlightjs/highlight.js/tree/master/src/styles
theme: atom-one-light
# Show copy code button
clipboard: true
# Default folding status of the code blocks. Can be "", "folded", "unfolded"
fold: unfolded
# Whether to show estimated article reading time
readtime: true
# Article licensing block
# licenses:
# Creative Commons:
# icon: fab fa-creative-commons
# url: "https://creativecommons.org/"
# Attribution:
# icon: fab fa-creative-commons-by
# url: "https://creativecommons.org/licenses/by/4.0/"
# Noncommercial:
# icon: fab fa-creative-commons-nc
# url: "https://creativecommons.org/licenses/by-nc/4.0/"
# Search plugin configurations
# https://ppoffice.github.io/hexo-theme-icarus/categories/Plugins/Search/
search:
type: insight
# Comment plugin configurations
# https://ppoffice.github.io/hexo-theme-icarus/categories/Plugins/Comment/
comment:
type: isso
url: comments.example.com

# type: gitalk
# client_id: 5517d968e8bd89976cdb
# client_secret: eb3f07f7e26e18c0ca3924193d1761346084147f
# repo: https://github.com/ehoac/ehoac_hexo_comment.git
# owner: ehoac
# admin:
# - ehoac
# language: zh-CN
# per_page: 20
# Donate plugin configurations
# https://ppoffice.github.io/hexo-theme-icarus/categories/Plugins/Donation/
donates:
# "Afdian.net" donate button configurations
# - type: afdian
# # URL to the "Afdian.net" personal page
# url: ""
# Alipay donate button configurations
- type: alipay
# Alipay qrcode image URL
qrcode: ""
# "Buy me a coffee" donate button configurations
# - type: buymeacoffee
# # URL to the "Buy me a coffee" page
# url: ""
# Patreon donate button configurations
# - type: patreon
# # URL to the Patreon page
# url: ""
# Paypal donate button configurations
# - type: paypal
# # Paypal business ID or email address
# business: ""
# # Currency code
# currency_code: USD
# Wechat donate button configurations
- type: wechat
# Wechat qrcode image URL
qrcode: ""
# Share plugin configurations
# https://ppoffice.github.io/hexo-theme-icarus/categories/Plugins/Share/
# share:
# type: sharethis
# # URL to the ShareThis share plugin script
# install_url: ""
# Sidebar configurations.
# Please be noted that a sidebar is only visible when it has at least one widget
sidebar:
# Left sidebar configurations
left:
# Whether the sidebar sticks to the top when page scrolls
sticky: false
# Right sidebar configurations
right:
# Whether the sidebar sticks to the top when page scrolls
sticky: false
# Sidebar widget configurations
# http://ppoffice.github.io/hexo-theme-icarus/categories/Widgets/
widgets:
# Profile widget configurations
- # Where should the widget be placed, left sidebar or right sidebar
position: left
type: profile
# Author name
author: Ehoac
# Author title
author_title: Your title
# Author's current location
# location: Your location
# URL or path to the avatar image
avatar:
# Whether show the rounded avatar image
avatar_rounded: false
# Email address for the Gravatar
# gravatar:
# URL or path for the follow button
# follow_link: "https://github.com/ppoffice"
# Links to be shown on the bottom of the profile widget
# social_links:
# Github:
# icon: fab fa-github
# url: "https://github.com/ppoffice"
# Facebook:
# icon: fab fa-facebook
# url: "https://facebook.com"
# Twitter:
# icon: fab fa-twitter
# url: "https://twitter.com"
# Dribbble:
# icon: fab fa-dribbble
# url: "https://dribbble.com"
# RSS:
# icon: fas fa-rss
# url: /
# Table of contents widget configurations
- # Where should the widget be placed, left sidebar or right sidebar
position: right
type: toc
# Whether to show the index of each heading
index: true
# Whether to collapse sub-headings when they are out-of-view
collapsed: true
# Maximum level of headings to show (1-6)
depth: 3
# Recommendation links widget configurations
# - # Where should the widget be placed, left sidebar or right sidebar
# position: left
# type: links
# # Names and URLs of the sites
# links:
# Hexo: "https://hexo.io"
# Bulma: "https://bulma.io"
# Categories widget configurations
- # Where should the widget be placed, left sidebar or right sidebar
position: right
type: categories
# Recent posts widget configurations
- # Where should the widget be placed, left sidebar or right sidebar
position: right
type: recent_posts
# Archives widget configurations
- # Where should the widget be placed, left sidebar or right sidebar
position: left
type: archives
# Tags widget configurations
- # Where should the widget be placed, left sidebar or right sidebar
position: left
type: tags
# Google FeedBurner email subscription widget configurations
# - # Where should the widget be placed, left sidebar or right sidebar
# position: left
# type: subscribe_email
# # Hint text under the email input
# description:
# # Feedburner ID
# feedburner_id: ""
# Google AdSense unit configurations
# - # Where should the widget be placed, left sidebar or right sidebar
# position: left
# type: adsense
# # AdSense client ID
# client_id: ""
# # AdSense AD unit ID
# slot_id: ""
# Plugin configurations
# https://ppoffice.github.io/hexo-theme-icarus/categories/Plugins/
plugins:
# Enable page startup animations
animejs: true
# Show the "back to top" button
back_to_top: true
# Baidu Analytics plugin settings
# https://tongji.baidu.com
baidu_analytics:
# Baidu Analytics tracking ID
tracking_id:
# Bing Webmaster Tools plugin settings
# https://www.bing.com/toolbox/webmaster/
bing_webmaster:
# Bing Webmaster Tools tracking ID in the <meta> tag
tracking_id:
# BuSuanZi site/page view counter
# https://busuanzi.ibruce.info
busuanzi:
enable: true
site_uv_offset: 0
site_pv_offset: 0
# CNZZ statistics
# https://www.umeng.com/web
cnzz:
# CNZZ tracker id
id:
# CNZZ website id
web_id:
# Alerting users about the use of cookies
# https://www.osano.com/cookieconsent/
cookie_consent:
# The compliance type. Can be "info", "opt-in", or "opt-out"
type: info
# Theme of the popup. Can be "block", "edgeless", or "classic"
theme: edgeless
# Whether the popup should stay static regardless of the page scrolls
static: false
# Where on the screen the consent popup should display
position: bottom-left
# URL to your site's cookie policy
policyLink: "https://www.cookiesandyou.com/"
# Enable the lightGallery and Justified Gallery plugins
gallery: true
# Google Analytics plugin settings
# https://analytics.google.com
google_analytics:
# Google Analytics tracking ID
tracking_id:
# Hotjar user feedback plugin
# https://www.hotjar.com/
hotjar:
# Hotjar site id
site_id:
# Enable the KaTeX math typesetting support
# https://katex.org/
katex: false
# Enable the MathJax math typesetting support
# https://www.mathjax.org/
mathjax: false
# Enable the Outdated Browser plugin
# http://outdatedbrowser.com/
outdated_browser: false
# Show a progress bar at top of the page on page loading
progressbar: true
# Statcounter statistics
# https://statcounter.com/
statcounter:
# Statcounter project id
project:
# Statcounter project security code
security:
# Twitter conversion tracking plugin settings
# https://business.twitter.com/en/help/campaign-measurement-and-analytics/conversion-tracking-for-websites.html
twitter_conversion_tracking:
# Twitter Pixel ID
pixel_id:
# CDN provider settings
# https://ppoffice.github.io/hexo-theme-icarus/Configuration/Theme/speed-up-your-site-with-custom-cdn/
providers:
# Name or URL template of the JavaScript and/or stylesheet CDN provider
cdn: jsdelivr
# Name or URL template of the webfont CDN provider
fontcdn: google
# Name or URL of the fontawesome icon font CDN provider
iconcdn: fontawesome

isso 评论系统

使用 python2 安装 isso 模块,python3 配置

1
2
3
4
5
6
7
8
9
10
11
12
# python 安装 isso 模块
pip install isso
# clone isso 项目
git clone https://github.com/posativ/isso.git
cd isso
# 安装依赖
python setup.py develop
# 安装js并压缩
make init js
# 启动 isso
isso run
# 使用supervisor建立守护进程

isso 项目配置

默认配置文件相对位置(/isso/share/isso.conf)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[general]
dbpath = /www/server/isso/db/comments.db
name =
# 博客地址
host =
http://blog.XXX.com/
http://localhost/

# 后台管理
[admin]
enabled = true

# Admin access password
password = admin_access_password

[server]
# 评论系统内网地址
listen = http://0.0.0.0:8081
# 评论系统外网地址
public-endpoint = http://comments.example.com

icarus 配置 _config.icarus.yml

1
2
3
comment:
type: isso
url: comments.example.com

评论系统配置参考 icarus 配置中 comments

使用 git 部署

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# 创建git用户并登录
useradd git
su git
# 设置git用户密码
passwd git
# 如果/home下没有git目录,创建一个
mkdir /home/git
#在git用户目录下创建密钥认证
cd /home/git
mkdir .ssh
cd .ssh
touch authorized_keys
# 初始化一个裸仓库
mkdir /home/git/repo
cd /home/git/repo
git init --bare blog.git
cd blog.git/hooks
# 编辑post-receive加入 work-tree 为 博客项目目录,推送时会将推送内容同步到博客目录
# #!/bin/sh
# git --work-tree=/home/git/projects/blog --git-dir=/home/git/repos/blog.git checkout -f
#

# 赋予post-receive执行权限
chmod +x post-receive
chown -R git:git /home/git/repo/blog.git

# 客户端生成并配置ssh-key
ssh-keygen -t rsa -C "youremail@example.com"
# 将公钥复制到 服务器/home/git/.ssh/authorized_keys

hexo 部署

配置 _config.yml

1
2
3
4
5
# 部署到git服务
deploy:
type: "git"
repo: git@XXX.com:/path/to/server/blog.git
branch: master

部署

1
hexo d
 评论