hexo-doc-搭建和使用

前提

  • 需要已安装nodejs

搭建

1
npm install hexo-cli -g

使用

初始化博客

1
2
3
hexo init blog
cd blog
npm install

启动博客

1
2
3
4
5
# 默认端口号是4000
hexo server

# 变更端口号
hexo server -p 端口号

next主题

hexo的yml变动

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
title: popo
subtitle: ''
description: ''
keywords: blog,game,program,server,dev,devlopment
author: popo
language: en
timezone: ''

search:
path: search.xml
field: post
content: false
format: html
limit: 10000

# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: next

next的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
custom_file_path:
#head: source/_data/head.njk
#header: source/_data/header.njk
#sidebar: source/_data/sidebar.njk
#postMeta: source/_data/post-meta.njk
#postBodyEnd: source/_data/post-body-end.njk
#footer: source/_data/footer.njk
#bodyEnd: source/_data/body-end.njk
#variable: source/_data/variables.styl
#mixin: source/_data/mixins.styl
style: source/_data/styles.styl

# Schemes
# scheme: Muse
#scheme: Mist
scheme: Pisces
#scheme: Gemini

menu:
home: / || fa fa-home
about: /about/ || fa fa-user
#tags: /tags/ || fa fa-tags
#categories: /categories/ || fa fa-th
#archives: /archives/ || fa fa-archive
#schedule: /schedule/ || fa fa-calendar
#sitemap: /sitemap.xml || fa fa-sitemap
#commonweal: /404/ || fa fa-heartbeat

math:
# Default (true) will load mathjax / katex script on demand.
# That is it only render those page which has `mathjax: true` in Front-matter.
# If you set it to false, it will load mathjax / katex srcipt EVERY PAGE.
per_page: true

# hexo-renderer-pandoc (or hexo-renderer-kramed) required for full MathJax support.
mathjax:
enable: true
# See: https://mhchem.github.io/MathJax-mhchem/
mhchem: false

# hexo-renderer-markdown-it-plus (or hexo-renderer-markdown-it with markdown-it-katex plugin) required for full Katex support.
katex:
enable: false
# See: https://github.com/KaTeX/KaTeX/tree/master/contrib/copy-tex
copy_tex: false

avatar:
# Replace the default image and set the url here.
url: /images/favicon.png
# If true, the avatar will be dispalyed in circle.
rounded: true
# If true, the avatar will be rotated with the cursor.
rotated: false

excerpt_description: true

back2top:
enable: true
# Back to top in sidebar.
sidebar: true
# Scroll percent label in b2t button.
scrollpercent: true

local_search:
enable: true
# If auto, trigger search by changing input.
# If manual, trigger search by pressing enter key or search button.
trigger: auto
# Show top n results per article, show all results by setting to -1
top_n_per_article: 1
# Unescape html strings to the readable one.
unescape: false
# Preload the search data when the page loads.
preload: false

自定义皮肤文件

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
// Custom styles.

// 首页post显示
.posts-expand .post {
box-sizing: border-box;
margin: 5px auto 20px;
padding: 8px;
border: 1px solid $grey-lighter;
box-shadow:2px 2px 7px #9fb6cd;

}

.post-block2 {
background:#F5F5F5;
padding: 8px;
border-bottom: 5px solid white;
}

// post内容的链接
.post-body p a{
color: #0593d3;
border-bottom: none;
border-bottom: 1px solid #0593d3;
&:hover {
color: #0593d3;
border-bottom: none;
border-bottom: 3px solid #0593d3;
}
}

.post-body img {
box-sizing: border-box;
margin: 5px auto 0px;
padding: 4px;
border: 3px solid $grey-lighter;
}

// post内容的引用
.post-body blockquote {
margin: 0;
padding: 0 15px;
background-color: #F5F5F5;
border-left: 8px solid #EEEEEE;

cite::before {
content: "-";
padding: 0 5px;
}
}

.post-body li{

color: #8F8F8F;
}

// post内容的居中
.post-body center{
color: #B0B0B0;
border-bottom: none;
border-bottom: 0px solid #0593d3;
font-size: 0.8em;
margin: -20px auto 15px;
}

// post文章的标题
.page-post-detail .post-title {
font-size: 35px;
text-align: center;
word-break: break-word;
font-weight: $posts-expand-title-font-weight
line-height:1em;
padding-bottom:.12em;
padding-top:.12em;

+mobile() {
font-size: 22px;
}
}

// post内容的标题
.post-body {
h1 {
font-size: 1.6em;
border-bottom: 1px solid $body-bg-color;
code {
font-size: 1em;
}
}
h2 {
color: #f15b6c;
font-size: 2em;
border-bottom: 1px solid $body-bg-color;
code {
font-size: 1em;
}
}
h3 {
color: #00ae9d;
font-size: 1.5em;
code {
font-size: 1em;
}
if use_seo {
border-bottom: 1px solid $body-bg-color;
} else {
border-bottom: 1px dotted $body-bg-color;
}
}
h4 {
color: #33a3dc;
font-size: 1.3em;
code {
font-size: 1em;
}
if use_seo {
border-bottom: 1px dotted $body-bg-color;
}
}
h5 {
color: #EE82EE;
font-size: 1.15em;
code {
font-size: 1em;
}
}
h6 {
font-size: 1.03em;
code {
font-size: 1em;
}
}

img {
box-sizing: border-box;
margin: 5px auto 0px;
padding: 4px;
border: 3px solid $grey-lighter;
}
}

首页post代码修改

post.njk

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
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
   {%- if is_index %}
{##################}
{### POST BLOCK ###}
{##################}

<article itemscope itemtype="http://schema.org/Article" class="post-block2" lang="{{ post.lang or config.language }}">
<link itemprop="mainEntityOfPage" href="{{ post.permalink }}">

<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="{{ url_for(theme.avatar.url or theme.images + '/avatar.gif') }}">
<meta itemprop="name" content="{{ author }}">
<meta itemprop="description" content="{{ description }}">
</span>

<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="{{ title }}">
</span>

{%- if post.header !== false %}
<header class="post-header">
<{%- if is_index %}h2{% else %}h1{%- endif %} class="post-title{%- if post.direction and post.direction.toLowerCase() === 'rtl' %} rtl{%- endif %}" itemprop="name headline">
{# Link posts #}
{%- if post.link %}
{%- if post.sticky > 0 %}
<span class="post-sticky-flag" title="{{ __('post.sticky') }}">
<i class="fa fa-thumbtack"></i>
</span>
{%- endif %}
{%- set postTitleIcon = '<i class="fa fa-external-link-alt"></i>' %}
{%- set postText = post.title or post.link %}
{{ next_url(post.link, postText + postTitleIcon, {class: 'post-title-link post-title-link-external', itemprop: 'url'}) }}
{% elif is_index %}
{%- if post.sticky > 0 %}
<span class="post-sticky-flag" title="{{ __('post.sticky') }}">
<i class="fa fa-thumbtack"></i>
</span>
{%- endif %}
{{ next_url(post.path, post.title or __('post.untitled'), {class: 'post-title-link', itemprop: 'url'}) }}
{%- else %}
{{- post.title }}
{{- post_edit(post.source) }}
{%- endif %}
</{%- if is_index %}h2{% else %}h1{%- endif %}>

<div class="post-meta">

{%- set date_diff = date(post.date) != date(post.updated) %}
{%- set time_diff = time(post.date) != time(post.updated) %}
{%- set datetime_diff = date_diff or time_diff %}

{%- if theme.post_meta.created_at %}
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">{{ __('post.posted') }}</span>

{%- if not date_diff and time_diff and theme.post_meta.updated_at.enable and theme.post_meta.updated_at.another_day %}
{%- set create_title = __('post.created') + __('symbol.colon') + full_date(post.date) + ' / ' + __('post.modified') + __('symbol.colon') + time(post.updated) %}
{% else %}
{%- set create_title = __('post.created') + __('symbol.colon') + full_date(post.date) %}
{%- endif %}

<time title="{{ create_title }}" itemprop="dateCreated datePublished" datetime="{{ moment(post.date).format() }}">{{ date(post.date) }}</time>
</span>
{%- endif %}

{%- if theme.post_meta.updated_at.enable and datetime_diff %}
{%- set display_updated = not theme.post_meta.updated_at.another_day or theme.post_meta.updated_at.another_day and date_diff %}

{%- if display_updated or not theme.post_meta.created_at %}
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">{{ __('post.edited') }}</span>
<time title="{{ __('post.modified') + __('symbol.colon') + full_date(post.updated) }}" itemprop="dateModified" datetime="{{ moment(post.updated).format() }}">{{ date(post.updated) }}</time>
</span>
{%- endif %}
{%- endif %}

{%- if post.categories and post.categories.length and theme.post_meta.categories %}
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder"></i>
</span>
<span class="post-meta-item-text">{{ __('post.in') }}</span>
{%- for cat in post.categories.toArray() %}
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="{{ url_for(cat.path) }}" itemprop="url" rel="index"><span itemprop="name">{{ cat.name }}</span></a>
</span>

{%- set cat_length = post.categories.length %}
{%- if cat_length > 1 and loop.index !== cat_length %}
{{ __('symbol.comma') }}
{%- endif %}
{%- endfor %}
</span>
{%- endif %}

{# LeanCloud PageView #}
{%- if theme.leancloud_visitors.enable or (theme.valine.enable and theme.valine.appId and theme.valine.appKey and theme.valine.visitor) %}
<span id="{{ url_for(post.path) }}" class="post-meta-item leancloud_visitors" data-flag-title="{{ post.title }}" title="{{ __('post.views') }}">
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">{{ __('post.views') + __('symbol.colon') }}</span>
<span class="leancloud-visitors-count"></span>
</span>
{%- endif %}

{%- if theme.firestore.enable %}
<span class="post-meta-item" title="{{ __('post.views') }}">
<span class="post-meta-item-icon">
<i class="fa fa-users"></i>
</span>
<span class="post-meta-item-text">{{ __('post.views') + __('symbol.colon') }}</span>
<span class="firestore-visitors-count"></span>
</span>
{%- endif %}

{%- if not is_index and theme.busuanzi_count.enable and theme.busuanzi_count.post_views %}
<span class="post-meta-item" title="{{ __('post.views') }}" id="busuanzi_container_page_pv" style="display: none;">
<span class="post-meta-item-icon">
<i class="{{ theme.busuanzi_count.post_views_icon }}"></i>
</span>
<span class="post-meta-item-text">{{ __('post.views') + __('symbol.colon') }}</span>
<span id="busuanzi_value_page_pv"></span>
</span>
{%- endif %}

{{- next_inject('postMeta') }}

{%- if config.symbols_count_time.symbols %}
{%- if theme.symbols_count_time.separated_meta %}<br>{%- endif %}
<span class="post-meta-item" title="{{ __('symbols_count_time.count') }}">
<span class="post-meta-item-icon">
<i class="far fa-file-word"></i>
</span>
{%- if theme.symbols_count_time.item_text_post %}
<span class="post-meta-item-text">{{ __('symbols_count_time.count') + __('symbol.colon') }}</span>
{%- endif %}
<span>{{ symbolsCount(post) }}</span>
</span>
{%- endif %}

{%- if config.symbols_count_time.time %}
<span class="post-meta-item" title="{{ __('symbols_count_time.time') }}">
<span class="post-meta-item-icon">
<i class="far fa-clock"></i>
</span>
{%- if theme.symbols_count_time.item_text_post %}
<span class="post-meta-item-text">{{ __('symbols_count_time.time') }} &asymp;</span>
{%- endif %}
<span>{{ symbolsTime(post, config.symbols_count_time.awl, config.symbols_count_time.wpm, __('symbols_count_time.time_minutes')) }}</span>
</span>
{%- endif %}

{%- if post.description and (not theme.excerpt_description or not is_index) %}
<div class="post-description">{{ post.description }}</div>
{%- endif %}

</div>
</header>
{%- endif %}

{#################}
{### POST BODY ###}
{#################}
<div class="post-body{%- if post.direction and post.direction.toLowerCase() === 'rtl' %} rtl{%- endif %}" itemprop="articleBody">

{# Gallery support #}
{%- if post.photos and post.photos.length %}
<div class="post-gallery" itemscope itemtype="http://schema.org/ImageGallery">
{%- for photo in post.photos %}
<img src="{{ url_for(photo) }}" itemprop="contentUrl">
{%- endfor %}
</div>
{%- endif %}

{%- if is_index %}
{%- if theme.read_more_btn %}
<div class="post-button">
<a class="btn" href="{{ url_for(post.path) }}">
{{ __('post.read_more') }} &raquo;
</a>
</div>
{%- endif %}

{%- if post.description and theme.excerpt_description %}
<p>{{ post.description }}</p>
<!--noindex-->

<!--/noindex-->
{% elif post.excerpt %}
{{ post.excerpt }}
<!--noindex-->
{%- if theme.read_more_btn %}
<div class="post-button">
<a class="btn" href="{{ url_for(post.path) }}#more" rel="contents">
{{ __('post.read_more') }} &raquo;
</a>
</div>
{%- endif %}
<!--/noindex-->
{% else %}
<!--{{ post.content }}-->
{%- endif %}
{% else %}
{{ post.content }}
{%- endif %}
</div>

{#####################}
{### END POST BODY ###}
{#####################}


</article>
{######################}
{### END POST BLOCK ###}
{######################}

{% else %}
{##################}
{### POST BLOCK ###}
{##################}

<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="{{ post.lang or config.language }}">
<link itemprop="mainEntityOfPage" href="{{ post.permalink }}">

<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="{{ url_for(theme.avatar.url or theme.images + '/avatar.gif') }}">
<meta itemprop="name" content="{{ author }}">
<meta itemprop="description" content="{{ description }}">
</span>

<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="{{ title }}">
</span>

{%- if post.header !== false %}
<header class="post-header">
<{%- if is_index %}h2{% else %}h1{%- endif %} class="post-title{%- if post.direction and post.direction.toLowerCase() === 'rtl' %} rtl{%- endif %}" itemprop="name headline">
{# Link posts #}
{%- if post.link %}
{%- if post.sticky > 0 %}
<span class="post-sticky-flag" title="{{ __('post.sticky') }}">
<i class="fa fa-thumbtack"></i>
</span>
{%- endif %}
{%- set postTitleIcon = '<i class="fa fa-external-link-alt"></i>' %}
{%- set postText = post.title or post.link %}
{{ next_url(post.link, postText + postTitleIcon, {class: 'post-title-link post-title-link-external', itemprop: 'url'}) }}
{% elif is_index %}
{%- if post.sticky > 0 %}
<span class="post-sticky-flag" title="{{ __('post.sticky') }}">
<i class="fa fa-thumbtack"></i>
</span>
{%- endif %}
{{ next_url(post.path, post.title or __('post.untitled'), {class: 'post-title-link', itemprop: 'url'}) }}
{%- else %}
{{- post.title }}
{{- post_edit(post.source) }}
{%- endif %}
</{%- if is_index %}h2{% else %}h1{%- endif %}>

<div class="post-meta">

{%- set date_diff = date(post.date) != date(post.updated) %}
{%- set time_diff = time(post.date) != time(post.updated) %}
{%- set datetime_diff = date_diff or time_diff %}

{%- if theme.post_meta.created_at %}
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">{{ __('post.posted') }}</span>

{%- if not date_diff and time_diff and theme.post_meta.updated_at.enable and theme.post_meta.updated_at.another_day %}
{%- set create_title = __('post.created') + __('symbol.colon') + full_date(post.date) + ' / ' + __('post.modified') + __('symbol.colon') + time(post.updated) %}
{% else %}
{%- set create_title = __('post.created') + __('symbol.colon') + full_date(post.date) %}
{%- endif %}

<time title="{{ create_title }}" itemprop="dateCreated datePublished" datetime="{{ moment(post.date).format() }}">{{ date(post.date) }}</time>
</span>
{%- endif %}

{%- if theme.post_meta.updated_at.enable and datetime_diff %}
{%- set display_updated = not theme.post_meta.updated_at.another_day or theme.post_meta.updated_at.another_day and date_diff %}

{%- if display_updated or not theme.post_meta.created_at %}
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">{{ __('post.edited') }}</span>
<time title="{{ __('post.modified') + __('symbol.colon') + full_date(post.updated) }}" itemprop="dateModified" datetime="{{ moment(post.updated).format() }}">{{ date(post.updated) }}</time>
</span>
{%- endif %}
{%- endif %}

{%- if post.categories and post.categories.length and theme.post_meta.categories %}
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder"></i>
</span>
<span class="post-meta-item-text">{{ __('post.in') }}</span>
{%- for cat in post.categories.toArray() %}
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="{{ url_for(cat.path) }}" itemprop="url" rel="index"><span itemprop="name">{{ cat.name }}</span></a>
</span>

{%- set cat_length = post.categories.length %}
{%- if cat_length > 1 and loop.index !== cat_length %}
{{ __('symbol.comma') }}
{%- endif %}
{%- endfor %}
</span>
{%- endif %}

{# LeanCloud PageView #}
{%- if theme.leancloud_visitors.enable or (theme.valine.enable and theme.valine.appId and theme.valine.appKey and theme.valine.visitor) %}
<span id="{{ url_for(post.path) }}" class="post-meta-item leancloud_visitors" data-flag-title="{{ post.title }}" title="{{ __('post.views') }}">
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">{{ __('post.views') + __('symbol.colon') }}</span>
<span class="leancloud-visitors-count"></span>
</span>
{%- endif %}

{%- if theme.firestore.enable %}
<span class="post-meta-item" title="{{ __('post.views') }}">
<span class="post-meta-item-icon">
<i class="fa fa-users"></i>
</span>
<span class="post-meta-item-text">{{ __('post.views') + __('symbol.colon') }}</span>
<span class="firestore-visitors-count"></span>
</span>
{%- endif %}

{%- if not is_index and theme.busuanzi_count.enable and theme.busuanzi_count.post_views %}
<span class="post-meta-item" title="{{ __('post.views') }}" id="busuanzi_container_page_pv" style="display: none;">
<span class="post-meta-item-icon">
<i class="{{ theme.busuanzi_count.post_views_icon }}"></i>
</span>
<span class="post-meta-item-text">{{ __('post.views') + __('symbol.colon') }}</span>
<span id="busuanzi_value_page_pv"></span>
</span>
{%- endif %}

{{- next_inject('postMeta') }}

{%- if config.symbols_count_time.symbols %}
{%- if theme.symbols_count_time.separated_meta %}<br>{%- endif %}
<span class="post-meta-item" title="{{ __('symbols_count_time.count') }}">
<span class="post-meta-item-icon">
<i class="far fa-file-word"></i>
</span>
{%- if theme.symbols_count_time.item_text_post %}
<span class="post-meta-item-text">{{ __('symbols_count_time.count') + __('symbol.colon') }}</span>
{%- endif %}
<span>{{ symbolsCount(post) }}</span>
</span>
{%- endif %}

{%- if config.symbols_count_time.time %}
<span class="post-meta-item" title="{{ __('symbols_count_time.time') }}">
<span class="post-meta-item-icon">
<i class="far fa-clock"></i>
</span>
{%- if theme.symbols_count_time.item_text_post %}
<span class="post-meta-item-text">{{ __('symbols_count_time.time') }} &asymp;</span>
{%- endif %}
<span>{{ symbolsTime(post, config.symbols_count_time.awl, config.symbols_count_time.wpm, __('symbols_count_time.time_minutes')) }}</span>
</span>
{%- endif %}

{%- if post.description and (not theme.excerpt_description or not is_index) %}
<div class="post-description">{{ post.description }}</div>
{%- endif %}

</div>
</header>
{%- endif %}

{#################}
{### POST BODY ###}
{#################}
<div class="post-body{%- if post.direction and post.direction.toLowerCase() === 'rtl' %} rtl{%- endif %}" itemprop="articleBody">

{# Gallery support #}
{%- if post.photos and post.photos.length %}
<div class="post-gallery" itemscope itemtype="http://schema.org/ImageGallery">
{%- for photo in post.photos %}
<img src="{{ url_for(photo) }}" itemprop="contentUrl">
{%- endfor %}
</div>
{%- endif %}

{%- if is_index %}
{%- if post.description and theme.excerpt_description %}
<p>{{ post.description }}</p>
<!--noindex-->
{%- if theme.read_more_btn %}
<div class="post-button">
<a class="btn" href="{{ url_for(post.path) }}">
{{ __('post.read_more') }} &raquo;
</a>
</div>
{%- endif %}
<!--/noindex-->
{% elif post.excerpt %}
{{ post.excerpt }}
<!--noindex-->
{%- if theme.read_more_btn %}
<div class="post-button">
<a class="btn" href="{{ url_for(post.path) }}#more" rel="contents">
{{ __('post.read_more') }} &raquo;
</a>
</div>
{%- endif %}
<!--/noindex-->
{% else %}
<!--{{ post.content }}-->
{%- endif %}
{% else %}
{{ post.content }}
{%- endif %}
</div>

{#####################}
{### END POST BODY ###}
{#####################}

{%- if theme.related_posts.enable and (theme.related_posts.display_in_home or not is_index) %}
{{ partial('_partials/post/post-related.njk') }}
{%- endif %}

{%- if not is_index %}
{{- next_inject('postBodyEnd') }}

{%- if post.reward_settings.enable %}
{{ partial('_partials/post/post-reward.njk') }}
{%- endif %}

{%- if theme.creative_commons.license and theme.creative_commons.post %}
{{ partial('_partials/post/post-copyright.njk') }}
{%- endif %}

{%- if theme.follow_me %}
{{ partial('_partials/post/post-followme.njk', {}, {cache: theme.cache.enable}) }}
{%- endif %}

<footer class="post-footer">
{%- if post.tags and post.tags.length %}
{%- set tag_indicate = '<i class="fa fa-tag"></i>' if theme.tag_icon else '#' %}
<div class="post-tags">
{%- for tag in post.tags.toArray() %}
<a href="{{ url_for(tag.path) }}" rel="tag">{{ tag_indicate }} {{ tag.name }}</a>
{%- endfor %}
</div>
{%- endif %}

{{ partial('_partials/post/post-footer.njk', {}, {cache: theme.cache.enable}) }}

{{ post_nav(post) }}
</footer>
{% else %}
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
{%- endif %}
</article>
{######################}
{### END POST BLOCK ###}
{######################}
{%- endif %}

搜索库

1
2
# local搜索库
npm install hexo-generator-searchdb

只搜索标题

找到next的local-sarch.js

1
2
3
99行添加 
keywords = []
keywords.push(searchText);

视频播放

1
npm install hexo-tag-dplayer --save
1
https://github.com/MoePlayer/hexo-tag-dplayer/blob/master/README.md#usage

修改数学公式显示

1
2
3
4
5
6
7
8
9
10
npm uninstall hexo-renderer-marked --save
npm install hexo-renderer-kramed --save

# 找到node_modules\kramed\lib\rules\inline.js,把第11行的 escape 变量的值做相应的修改:
//escape: /^\\([\\`*{}\[\]()#$+\-.!_>])/,
escape: /^\\([`*\[\]()#$+\-.!_>])/,

# 把第20行的em变量也要做相应的修改。
//em: /^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
em: /^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,

问题

hexo后台一直运行

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 安装pm2
npm install -g pm2

# 编写运行脚本 backrun.js
const { exec } = require('child_process')
exec('hexo server -p 80',(error, stdout, stderr) => {
if(error){
console.log('exec error: ${error}')
return
}
console.log('stdout: ${stdout}');
console.log('stderr: ${stderr}');
})

// 运行脚本
pm2 start backrun.js