Sorry, your browser cannot access this site
This page requires browser support (enable) JavaScript
Learn more >

这是我的第一篇博客,也是本站的部署记录。

1 前言

相信每一个想部署个人博客的小伙伴们都想快速上手个人博客。在众多框架中,hexo以庞大的使用群体胜出,成为了我的选择。而Volantis主题又以清新脱俗的小众化吸引了我的注意。

在网站的部署上,我选择部署在GitHub pages(毕竟谁不喜欢有稳定又白能嫖的渠道呢)。碍于国内访问速度过慢,我将网站上传CDN提升国内访问速度,并使用了自己的域名blog.xinghenluyus.cn.

本站仅提供个人部署思路.

2 Hexo安装

2.1 环境配置

具体教材可以自行上网搜索

2.2 安装Hexo

点击这里前往Hexo官方文档。

全局安装npm

1
2
3
4
npm install -g hexo-cli

//国内镜像源也可以使用
cnpm install -g hexo-cli

初始化博客文件夹

1
2
//cd到要存放博客的本地文件夹
hexo init myblog

安装相关依赖

1
2
cd myblog
npm install

启动服务

1
2
hexo g 
hexo server

按照提示打开浏览器

访问http://localhost:4000/,出现下图界面则部署成功。

本地浏览器界面
本地浏览器界面

之后,就可以在source/_posts中创建md文件写自己的代码啦,也可以用new命令,个人感觉没必要,直接创建,省时省力

每次更改Hexo代码后,都要重新启动服务

2.3 部署到GitHub Pages

如果你跟我一样把网站托管到GitHub,最好是有一个科学上网工具。

创建GitHub仓库

登录GitHub,new 一个 Repository,Repository name一定要是你的用户名.github.io。如下图所示,报错是因为仓库已经存在

新建仓库页面
新建仓库页面

第一次使用时出现下图报错,推荐直接删除仓库重新创建!

安装git插件

1
npm install hexo-deployer-git --save

修改blog/_config.yml配置文件

找到下文代码段,覆盖修改。其中yourname替换成自己的github用户名。

blog/_config.yml
1
2
3
4
5
6
7
# Deployment
## Docs: https://hexo.io/docs/one-command-deployment
deploy:
type: git
repository: https://github.com/yourname/yourname.github.io.git
branch: main

全部完成后,执行如下命令:

1
2
hexo c && hexo g && hexo d  
# hexo d 表示执行部署, hexo c 会清除hexo g 生成的文件,一般连用

命令行最后一行输出如下信息则表示上传成功:

1
INFO  Total precache size is about 1.98 MB for 26 resources.

执行成功可以通过yourname.github.io来访问博客了。

2.4 安装Volantis主题(可选)

  • 这里我采用npm安装

blog/_config.yml文件中找到并修改:

blog/_config.yml
1
2
3
4
# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: volantis

npm下载主题

1
2
//cd到个人博客本地根目录
npm i hexo-theme-volantis

2.5 配置Volantis主题(可选)

博客根目录下新建 _config.volantis.yml文件,这是主题自带的配置文件,可以覆盖blog\node_modules\hexo-theme-volantis_config.yml的配置,起到主题全局配置的作用。

  • 这里推荐一个我参考的博客,具体配置这里不再赘述:
我的_config.volantis.yml文件 (点击展开)
blog/_config.volantis.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
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
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
############################### Navigation Bar ############################### > start
# 注意事项:建议规范全站路径 URL 最后带一个 "/" 例如 "about/"
navbar:
visiable: auto # always, auto
logo: # choose [img] or [icon + title]
img: volantis-static/media/org.volantis/blog/Logo-NavBar@3x.png # https://gcore.jsdelivr.net/gh/volantis-x/cdn-org/blog/Logo-NavBar@3x.png
icon:
title:
menu:
- name: 博客
icon: fa-solid fa-rss
url: /
- name: 分类
icon: fa-solid fa-folder-open
url: categories/
- name: 标签
icon: fa-solid fa-tags
url: tags/
- name: 归档
icon: fa-solid fa-archive
url: archives/
- name: 友链
icon: fa-solid fa-link
url: friends/
- name: 关于
icon: fa-solid fa-info-circle
url: about/
search: Search... # Search bar placeholder
############################### Navigation Bar ############################### > end

############################### Cover ############################### > start
cover:
height_scheme: full # full, half
layout_scheme: dock # blank (留白), search (搜索), dock (坞), featured (精选), focus (焦点)
display:
home: true
archive: true
others: false # can be written in front-matter 'cover: true'
background: #https://gcore.jsdelivr.net/gh/MHG-LAB/cron@gh-pages/bing/bing.jpg
# background: https://bing.ioliu.cn/v1/rand?w=1920&h=1200
logo: # https://gcore.jsdelivr.net/gh/volantis-x/cdn-org/blog/Logo-Cover@3x.png
title: '<font><span>Hello</span> <span>Travelers</span></font>'
subtitle: <div id="binft"></div>
search: 在这里搜索Luyus的博客 # search bar placeholder
features:
- name: 主页
icon: #
url: /
- name: 分类
icon: #
url: categories/
- name: 标签
icon: #
url: tags/
- name: 归档
icon: #
url: archives/
- name: 友链
icon: #
url: friends/
- name: 关于
icon: #
url: about/
############################### Cover ############################### > end

pages:
# 友链页面配置
friends:
layout_scheme: simple # simple: 简单布局, traditional: 传统布局

search:
enable: true
service: hexo



### 自定义右键 新
rightmenus:
enable: true
# 右键菜单项及加载顺序
# 内容示例:plugins.[组名], menus.[组名], hr(分割线,推荐去线留白), music(音乐控制器)
order:
- plugins.navigation
- hr
- plugins.inputBox #文本输入框
- plugins.seletctText #选中文本
- plugins.elementCheck #链接判断
- plugins.elementImage #图片判断
- menus.link
- hr
- menus.darkMode
- plugins.articlePage
- hr
- music
############################
# - {id: '', name: '', icon: '', link: '', event: '', group: ''}
# id: 唯一值
# name: 用于菜单名称显示
# icon: 用于菜单图标显示
# link: 跳转链接
# event: 事件,当输入内容不为内置事件时,作 JavaScript 代码执行
# group: 菜单项所处分组名称
# 注:
# 1. link/event 二选一,同时出现时仅处理 link
# 2. 内置事件列表: copyText, copyLink, copyPaste, copyAll, copyCut, copyImg, printMode, readMode
# 3. 内置组列表:navigation, inputBox, seletctText, elementCheck, elementImage, articlePage
# 4. plugins 列允许自定义组内项目
# 5. menus 列允许自定义组及其内容
# 6. 除 navigation 外的内置组,在显示时会隐藏含 link 属性的菜单项
###########################
# 基础项设置
options:
# 图标前缀 fa-solid, fa-regular, fa-light, fa-thin, fa-duotone, fa-brands
iconPrefix: fa-solid
# 例外,在 articlePage 组显示时(文章页)时依旧显示含 link 属性的菜单项
articleShowLink: true
# 当设定全局音乐播放器时,是否一直显示音乐控制菜单。false:仅当音乐播放时启用
musicAlwaysShow: true
# 适用于复制图片文件的场景,当图片源未设置 Access-Control-Allow-Origin 时,图片复制由于 CORS 问题失败
# 你可以自行部署相应项目解决该问题,详见:https://github.com/Rob--W/cors-anywhere 或者 https://github.com/Zibri/cloudflare-cors-anywhere
corsAnywhere:
# 右键内置组,预置实现
plugins:
# 导航组件
# 横向排列,共用一行,仅显示图标 (原则上支持的数量不限)
navigation:
- {id: 'left', name: '转到上一页', icon: 'fa-solid fa-arrow-left', event: 'history.back()', group: 'navigation'}
- {id: 'right', name: '转到下一页', icon: 'fa-solid fa-arrow-right', event: 'history.forward()', group: 'navigation'}
- {id: 'redo', name: '刷新当前页面', icon: 'fa-solid fa-redo', event: 'window.location.reload()', group: 'navigation'}
- {id: 'up', name: '回到顶部', icon: 'fa-solid fa-arrow-up', event: 'VolantisApp.scrolltoElement(volantis.dom.bodyAnchor)', group: 'navigation'}
# - {id: 'home', name: '回到首页', icon: 'fa-solid fa-home', link: '/', group: 'navigation'}
# 文本输入框相关组件
# 生效于 input/textarea,粘贴、剪切、全选
inputBox:
- {id: 'copyPaste', name: '粘贴文本', icon: 'fa-solid fa-paste', event: 'copyPaste', group: 'inputBox'}
- {id: 'copyAll', name: '全选文本', icon: 'fa-solid fa-object-ungroup', event: 'copyAll', group: 'inputBox'}
- {id: 'copyCut', name: '剪切文本', icon: 'fa-solid fa-cut', event: 'copyCut', group: 'inputBox'}
# 文本选中类组件
# 生效于右键选中文本,__text__ 为选中的文本。
seletctText:
- {id: 'copyText', name: '复制文本', icon: 'fa-solid fa-copy', event: 'copyText', group: 'seletctText'}
- {id: 'searchWord', name: '站内搜索', icon: 'fa-solid fa-search', event: 'OpenSearch(__text__)', group: 'seletctText'}
- {id: 'bingSearch', name: '必应搜索', icon: 'fa-solid fa-search', event: 'window.open(`https://cn.bing.com/search?q=${__text__}`)', group: 'seletctText'}
#- {id: 'googleSearch', name: '谷歌搜索', icon: 'fa-solid fa-search', event: 'window.open(`https://www.google.com/search?q=${__text__}`)', group: 'seletctText'}
# 链接判断组件
# 生效于链接处的右键行为,__link__ 为链接地址
elementCheck:
- {id: 'openTab', name: '新标签页打开', icon: 'fa-solid fa-external-link-square-alt', event: 'window.open(__link__)', group: 'elementCheck'}
- {id: 'copyLink', name: '复制链接地址', icon: 'fa-solid fa-link', event: 'copyLink', group: 'elementCheck'}
# 图片判断类组件
# 生效于图片类的右键行为,__link__ 为链接地址
elementImage:
- {id: 'openImg', name: '打开图片', icon: 'fa-solid fa-image', event: 'window.open(`${__link__}`)', group: 'elementImage'}
# - {id: 'copyImg', name: '复制图片', icon: 'fa-solid fa-image', event: 'copyImg', group: 'elementImage'}
# - {id: 'googleImg', name: '谷歌识图', icon: 'fa-solid fa-images', event: 'window.open(`https://www.google.com.hk/searchbyimage?image_url=${__link__}`)', group: 'elementImage'}
# 文章页面组件
# 生效于 post.article 页面
articlePage:
# - {id: 'printMode', name: '打印页面', icon: 'fa-solid fa-print', event: 'printMode', group: 'articlePage'}
- {id: 'readMode', name: '阅读模式', icon: 'fa-solid fa-book-open', event: 'readMode', group: 'articlePage'}
# 右键自定义菜单区域
menus:
link:
- {id: 'home', name: '回到首页', icon: 'fa-solid fa-home', link: '/', group: 'link'}
- {id: 'openBgImg', name: '查看背景', icon: 'fa-solid fa-cloud', event: 'openCurrentBgImage()', group: 'link'}
# - {id: 'help', name: '常见问题', icon: 'fa-solid fa-question', link: 'https://volantis.js.org/faqs/', group: 'link'}
# - {id: 'examples', name: '示例博客', icon: 'fa-solid fa-rss', link: 'https://volantis.js.org/examples/', group: 'link'}
# - {id: 'contributors', name: '加入社区', icon: 'fa-solid fa-fan', link: 'https://volantis.js.org/contributors/', group: 'link'}
# - hr
# - {id: 'source_docs', name: '本站源码', icon: 'fa-solid fa-code-branch', link: 'https://github.com/volantis-x/volantis-docs/', group: 'link'}
# - {id: 'source_theme', name: '主题源码', icon: 'fa-solid fa-code-branch', link: 'https://github.com/volantis-x/hexo-theme-volantis/', group: 'link'}
darkMode:
- {id: 'darkMode', name: '暗黑模式', icon: 'fa-solid fa-moon', event: 'volantis.dark.toggle()', group: 'darkMode'}
###


############################### Sidebar ############################### > start
sidebar:
position: right # left right
# 主页、分类、归档等独立页面
for_page: [blogger, category, tagcloud, webinfo]
# layout: docs/post 这类文章页面
for_post: [blogger, toc]
# 侧边栏组件库
widget_library:
# ---------------------------------------
# blogger info widget
blogger:
class: blogger
display: [desktop, mobile] # [desktop, mobile]
avatar: volantis-static/media/org.volantis/blog/Logo-NavBar@3x.png # https://gcore.jsdelivr.net/gh/volantis-x/cdn-org/blog/Logo-NavBar@3x.png
shape: rectangle # circle, rectangle
url: /about/
title: #######
subtitle:
jinrishici: false # Poetry Today. You can set a string, and it will be displayed when loading fails.
customword: 一个专注于分享踩坑的小站.
social:
- icon: fas fa-rss
url: https://github.com/volantis-x/hexo-theme-volantis/
- icon: fa-solid fa-envelope
url: mailto:2593026969@qq.com
- icon: fab fa-github
url: https://github.com/xinghenLuyus/
# ---------------------------------------
# toc widget (valid only in articles)
toc:
class: toc
display: [desktop, mobile] # [desktop, mobile]
sticky: true
header:
icon: fa-solid fa-list
title: 本文目录
list_number: false
min_depth: 2
max_depth: 5
# ---------------------------------------
# music
music:
class: music
display: [desktop, mobile] # [desktop, mobile]
pjaxReload: false
# ---------------------------------------
# category widget
category:
class: category
display: [desktop] # [desktop, mobile]
header:
icon: fa-solid fa-folder-open
title: 文章分类
url: /blog/categories/
# ---------------------------------------
# tagcloud widget
tagcloud:
class: tagcloud
display: [desktop, mobile] # [desktop, mobile]
header:
icon: fa-solid fa-tags
title: 热门标签
url: /blog/tags/
min_font: 14
max_font: 24
color: true
start_color: '#999'
end_color: '#555'
# ---------------------------------------
# webinfo widget
webinfo:
class: webinfo
display: [desktop]
header:
icon: fa-solid fa-award
title: 站点信息
type:
article:
enable: true
text: '文章数目:'
unit: '篇'
runtime:
enable: false
data: '2025/02/28' # 填写建站日期
text: '已运行时间:'
unit: '天'
wordcount:
enable: true
text: '本站总字数:' # 需要启用 wordcount
unit: '字'
visitcounter:
siteuv:
enable: true
text: '本站访客数:'
unit: '人'
sitepv:
enable: true
text: '本站总访问量:'
unit: '次'
lastupd:
enable: true
friendlyShow: true # 更友好的时间显示
text: '最后活动时间:'
unit: '日'
# ---------------------------------------
# lastupdate widget
lastupdate:
class: lastupdate
display: [desktop, mobile]
header:
icon: fa-solid fa-clock WISTERIA
title: 最近更新
############################### Sidebar ############################### > end


#自定义网页底部
site_footer:
# layout of footer: [aplayer, social, license, info, copyright]
layout: [aplayer, copyright]
copyright: '[欣赏一下我喜欢的歌呀~](/)'
# You can add your own property here. (Support markdown, for example: br: '<br>')


plugins:
# 文章字数统计、阅读时长,开启需要安装插件: npm i --save hexo-wordcount
wordcount:
enable: true

# 暗黑模式 darkmode
# 开关按钮:在 navbar.menu 中添加:
# - name: 暗黑模式 # 可自定义
# icon: fa-solid fa-moon # 可自定义
# toggle: darkmode
darkmode:
enable: true

# APlayer is only available in mainland China.
# APlayer config: https://github.com/metowolf/MetingJS
aplayer:
enable: true
# Required
server: netease # netease, tencent, kugou, xiami, baidu歌曲的网站
type: song # song, playlist, album, search, artist 歌曲或者歌单、专辑等
id: ####### # song id / playlist id / album id / search keyword歌曲或者歌单的id
# Optional
fixed: false # enable fixed mode
theme: '#1BCDFC' # main color
autoplay: false # audio autoplay是否自动播放
order: list # player play order, values: 'list', 'random'
loop: one # player loop play, values: 'all', 'one', 'none'
volume: 0.7 # default volume, notice that player will remember user setting, default volume will not work after user set volume themselves
list_max_height: 320px # list max height
list_folded: true
autoHide: false # hide automaticaly是否要隐藏

parallax:
#背景设置
enable: true
position: fixed # cover: sticky on the cover. fixed: Fixed as background for the site.
shuffle: true # shuffle playlist
duration: 10000 # Duration (ms)
fade: 1500 # fade duration (ms) (Not more than 1500)
images: # For personal use only. At your own risk if used for commercial purposes !!!
- https://your.cdn.url



############################### Article Layout ############################### > start
# 文章布局
article:
# 文章列表页面的文章卡片布局方案
preview:
scheme: lanscape # landscape
# pin icon for post
pin_icon: volantis-static/media/twemoji/assets/svg/1f4cc.svg # https://gcore.jsdelivr.net/gh/twitter/twemoji@13.0/assets/svg/1f4cc.svg
# auto generate title if not exist
auto_title: true # false, true
# auto generate excerpt if not exist
auto_excerpt: true # false, true
# hide excerpt
hide_excerpt: false
# show split line or not
line_style: solid # hidden, solid, dashed, dotted
# show author
author: false # true, false
# show readmore button
readmore: auto # auto, always
# 文章详情页面的文章卡片本体布局方案
body:
# 文章顶部信息
# 从 meta_library 中取
top_meta: [date, category, tags, counter] #启用评论数量需在此添加
# 文章底部信息
# 从 meta_library 中取
bottom_meta: [updated, wordcount, walinecount, share]
# ----------------
# 文章页脚组件
footer_widget:
# ----------------
# 参考资料、相关资料等 (for layout: post/docs)
references:
title: 参考资料
icon: fa-solid fa-quote-left
# 在 front-matter 中:
# references:
# - title: 某篇文章
# url: https://
# 即可显示此组件。
# ----------------
# 相关文章,需要安装插件 (for layout: post)
# npm i hexo-related-popular-posts
related_posts:
enable: false
title: 相关文章
icon: fa-solid fa-bookmark
max_count: 5
# 设为空则不使用文章头图
placeholder_img: https://gcore.jsdelivr.net/gh/MHG-LAB/cron@gh-pages/bing/bing.jpg
# ----------------
# 版权声明组件 (for layout: post)
copyright:
enable: false
permalink: '本文永久链接是:'
content:
- '博客内容遵循 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) 协议'
- permalink
# 自定义版权组件:精细到文章的版权声明
custom: true # 开启后替代上方内容的版权显示
customData:
default: type1 # 默认授权声明
#############################
# 你可以在文章的 front-matter 覆盖默认版权声明
# 配置示例(均可选):
# copyright:
# type: type3 # 当前文章版权声明类型
# author: 张三 # 本文作者
# ref: # 原文出处
# title: # 原文出处 - 标题
# url: # 原文出处 - 链接
#############################
rules:
type1:
text: <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh#" target="_blank">CC BY-NC-SA 4.0</a>
desc: 署名-非商业性使用-相同方式共享 4.0 国际。
type2:
text: 禁止转载引用
desc: 除非获得原作者的单独授权,任何第三方不得转载!
type3:
text: 原作许可协议
desc: 本文转载自他站,转载或引用本文时,请遵守原作许可协议!
type4:
text: 来自互联网
desc: 本文来自互联网,未知来源,侵权请联系删除。
type5:
text: 允许规范转载
desc: 转载请保留本文转载地址,著作权归作者所有!
type6:
text: 允许付费转载
desc: 您可以联系作者通过付费方式获得授权。
# 还能自行添加更多
# ----------------
# 打赏组件 (for layout: post)
donate:
enable: false
images:
- volantis-static/media/org.volantis/blog/qrcode/github@volantis.png # https://gcore.jsdelivr.net/gh/volantis-x/cdn-org/blog/qrcode/github@volantis.png
- volantis-static/media/org.volantis/blog/qrcode/github@volantis.png # https://gcore.jsdelivr.net/gh/volantis-x/cdn-org/blog/qrcode/github@volantis.png
# meta library
meta_library:
# 默认文章作者(可在 _data/author.yaml 中增加其他作者,并在 front-matter 中设置)
# https://volantis.js.org/advanced-settings/#多人协同
author:
avatar: #文章作者的头像 # https://gcore.jsdelivr.net/gh/volantis-x/cdn-org/blog/favicon/apple-touch-icon.png
name: #作者名字
url: /
# 文章创建日期
date:
icon: fa-solid fa-calendar-alt
title: '发布于:'
format: 'll' # 日期格式 http://momentjs.com/docs/
# 文章更新日期
updated:
icon: fa-solid fa-edit
title: '更新于:'
format: 'll' # 日期格式 http://momentjs.com/docs/
# 文章分类
category:
icon: fa-solid fa-folder-open
# 文章浏览计数
counter:
icon: fa-solid fa-eye
unit: '次浏览'
# waline 文章评论数量
walinecount:
icon: fa-solid fa-comment-dots
desc: '条评论' # 条评论
# artalk 文章评论数量
artalkcount:
icon: fa-solid fa-comment-dots
desc: '条评论' # 条评论
# 文章字数和阅读时长
wordcount:
icon_wordcount: fa-solid fa-keyboard
icon_duration: fa-solid fa-hourglass-half
# 文章标签
tags:
icon: fa-solid fa-hashtag
# 分享
share:
- id: qq
img: volantis-static/media/org.volantis/logo/128/qq.png # https://gcore.jsdelivr.net/gh/volantis-x/cdn-org/logo/128/qq.png
# - id: qzone
# img: volantis-static/media/org.volantis/logo/128/qzone.png # https://gcore.jsdelivr.net/gh/volantis-x/cdn-org/logo/128/qzone.png
# - id: weibo
# img: volantis-static/media/org.volantis/logo/128/weibo.png # https://gcore.jsdelivr.net/gh/volantis-x/cdn-org/logo/128/weibo.png
- id: qrcode # 当id为qrcode时需要安装插件 npm i hexo-helper-qrcode
img: volantis-static/media/org.volantis/logo/128/wechat.png # https://gcore.jsdelivr.net/gh/volantis-x/cdn-org/logo/128/wechat.png
- id: telegram
img: volantis-static/media/org.volantis/logo/128/telegram.png # https://gcore.jsdelivr.net/gh/volantis-x/cdn-org/logo/128/telegram.png
############################### Article Layout ############################### > end


custom_css:
body:
effect: [shadow, blur] # [shadow, floatable, blur]
highlight:
language: true # show language of codeblock
grayscale: false # Enable grayscale effect
text_align: # left, right, justify, center
h1: left
h2: left
h3: left
h4: left
p: justify
fontfamily:
logofont:
fontfamily: '"Varela Round", "PingFang SC", "Microsoft YaHei", Helvetica, Arial'
name: 'Varela Round'
url: volantis-static/media/fonts/VarelaRound/VarelaRound-Regular.ttf # https://gcore.jsdelivr.net/gh/volantis-x/cdn-fonts/VarelaRound/VarelaRound-Regular.ttf
weight: normal
style: normal
bodyfont:
fontfamily: 'UbuntuMono, "Varela Round", "PingFang SC", "Microsoft YaHei", Helvetica, Arial'
name: 'UbuntuMono'
url: volantis-static/media/fonts/UbuntuMono/UbuntuMono-Regular.ttf # https://gcore.jsdelivr.net/gh/volantis-x/cdn-fonts/UbuntuMono/UbuntuMono-Regular.ttf
weight: normal
style: normal
codefont:
fontfamily: 'Menlo, UbuntuMono, Monaco'
name: 'Monaco'
url: volantis-static/media/fonts/Monaco/Monaco.ttf # https://gcore.jsdelivr.net/gh/volantis-x/cdn-fonts/Monaco/Monaco.ttf
weight: normal
style: normal
scrollbar:
size: 4px
border: 2px
color: '#2196f3'
hover: '#ff5722'



color_scheme:
# ------------
# 通用颜色
common:
# 主题色
theme: '#44D7B6'
# 链接色
link: '#2196f3'
# 按钮色
button: '#44D7B6'
# 鼠标放到交互元素上时的色
hover: '#ff5722'
# 主题色块内部的文字颜色
inner: '#fff'
# 选中区域文字的背景颜色
selection: 'alpha(#2196f3, 0.2)'
# ------------
# 亮色主题(默认)
light:
# 网站背景色
site_bg: '#f4f4f4'
# 网站背景上的文字
site_inner: '#fff'
# 网站页脚文字
site_footer: '#fff'

# 卡片背景色
card: '#fff'
# 卡片上的普通文字
text: '#444'

# 区块和代码块背景色
block: '#f6f6f6'
# 代码块高亮时的背景色
codeblock: '#f6f6f6'
# 行内代码颜色
inlinecode: '#D56D28'

# 文章部分
h1: '#444'
h2: '#444'
h3: '#444'
h4: '#444'
h5: '#444'
h6: '#444'
p: '#444'

# 列表文字
list: '#666'
# 列表 hover 时的文字
list_hl: 'mix($color-theme, #000, 80)'
# 辅助性文字
meta: '#888'
# ------------
# 暗色主题
dark:
# 网站背景色
site_bg: '#222'
# 网站背景上的文字
site_inner: '#eee'
# 网站页脚文字
site_footer: '#aaa'
# 卡片背景色
card: '#444'
# 卡片上的普通文字
text: '#eee'

# 区块和代码块背景色
block: '#3a3a3a'
# 代码块高亮时的背景色
codeblock: '#343a3c'
# 行内代码颜色
inlinecode: '#D56D28'

# 文章部分
h1: '#eee'
h2: '#eee'
h3: '#ddd'
h4: '#ddd'
h5: '#ddd'
h6: '#ddd'
p: '#bbb'

# 列表文字
list: '#aaa'
# 列表 hover 时的文字
list_hl: 'mix($color-theme, #fff, 80)'
# 辅助性文字
meta: '#888'
# 夜间图片亮度
brightness: 70%
body:
effect: [blur] # [shadow, floatable, blur]
highlight:
language: true # show language of codeblock
copy_btn: true



analytics:
# 不蒜子访问统计
busuanzi: https://gcore.jsdelivr.net/gh/volantis-x/cdn-busuanzi@2.3/js/busuanzi.pure.mini.js
leancloud: # 请使用自己的 id & key 以防止数据丢失
app_id: # 应用 APP_ID
app_key: # 应用 APP_KEY
custom_api_server: # 国际版一般不需要写,除非自定义了 API Server

############################### Comments ############################### > start
comments:
title: <i class='fa-solid fa-comments'></i> 评论
subtitle:
service: giscus
# 可选评论系统 #
# giscus
# https://giscus.app
# https://github.com/laymonage/giscus
giscus:
# 以下配置按照 yml 格式增删填写即可
repo: yourrepo/comments
repo-id: #######
category: Announcements
category-id: #######
mapping: "pathname"
reactions-enabled: "1"
emit-metadata: "0"
lang: "zh-CN"
# 以上配置按照 yml 格式增删填写即可
theme:
light: "light" # https://gcore.jsdelivr.net/gh/volantis-x/cdn-volantis@master/css/giscus/light.css
dark: "dark" # https://gcore.jsdelivr.net/gh/volantis-x/cdn-volantis@master/css/giscus/dark.css
############################### Comments ############################### > end

我的_config.yml(点击展开)
blog/_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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/

# Site
title: Luyus' Blog
subtitle: 'A website for recording technical learning'
description: '星痕的个人博客——Luyus的技术之旅,专注于技术学习与分享。在这里,我将记录自己在编程、网络、运维等领域的探索历程,与你一同成长。Star Trace’s Personal Blog – Luyus’ Tech Journey, dedicated to the exploration and sharing of technology. Here, I document my adventures in programming, networking, and system operations, inviting you to grow alongside me.'
keywords: blog, Luyus, tech, technology, programming, network, operation, system, development, learning, sharing, growth, exploration, adventure, journey, record, explore, discover, study, research, experience, knowledge, information, resource, guide, tutorial, solution, problem, challenge, solution, code, script, tool, software, hardware, service, platform, website, blog, post, article, content, writing, reading, thinking, idea, thought, opinion, view, perspective, insight, inspiration, motivation, encouragement, support, help, assistance, advice, suggestion, recommendation, reference, resource, link
author: Luyus
language: en
timezone: 'Asia/Shanghai'

# URL
## Set your site url here. For example, if you use GitHub Page, set url as 'https://username.github.io/project'
url: https://your.cdn.blog/
permalink: :year/:month/:day/:title/
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
syntax_highlighter: highlight.js
highlight:
line_number: true
auto_detect: false
tab_replace: ''
wrap: true
hljs: false
prismjs:
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

# Include / Exclude file(s)
## include:/exclude: options only apply to the 'source/' folder
include:
exclude:
ignore:

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

# Deployment
## Docs: https://hexo.io/docs/one-command-deployment
deploy:
type: git
repository: https://github.com/yourrepo.github.io.git
branch: main

# offline config passed to sw-precache.
service_worker:
maximumFileSizeToCacheInBytes: 5242880
staticFileGlobs:
- public/**/*.{js,html,css,png,jpg,gif,svg,eot,ttf,woff,woff2}
stripPrefix: public
verbose: true

# # ...existing code...
# #自定义生成静态文件脚本
# scripts:
# - scripts/generate-extra-file.js
# # ...existing code...
我的npm结构如下(点击展开)

终端运行npm list,得到包结构图,有缺失的请自行下载。

npm list
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
hexo-site@0.0.0 D:\wenjian\stepsave\blog\myblog
├── @jiangtj/hexo-extend-theme@0.2.4
├── hexo-deployer-git@4.0.0
├── hexo-generator-archive@2.0.0
├── hexo-generator-category@2.0.0
├── hexo-generator-index@4.0.0
├── hexo-generator-json-content@4.2.3
├── hexo-generator-tag@2.0.0
├── hexo-helper-qrcode@1.0.2
├── hexo-offline-popup@1.0.3
├── hexo-renderer-ejs@2.0.0
├── hexo-renderer-marked@7.0.0
├── hexo-renderer-stylus@3.0.1
├── hexo-server@3.0.0
├── hexo-theme-landscape@1.1.0
├── hexo-theme-volantis@5.8.0
├── hexo-wordcount@6.0.1
└── hexo@7.3.0

2.6 关于魔改

  • 强烈推荐DearXuan老师的魔改教程,讲的很仔细全面。
我的魔改
blog\source\_volantis\headBegin.ejs
1
2
3
<script src="https://unpkg.com/jquery@3.6.0/dist/jquery.min.js"></script>
<script defer src="/custom.js"></script>
<!-- <link rel="stylesheet" href="https://example.com/custom.css"> -->
blog\source\_volantis\style.styl
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
// 添加透明度
#l_main .post,
#l_side .widget
opacity: 0.8

// 文章不透明,否则会影响阅读
#post.post,
#docs.post
opacity: 1

//背景亮度
.parallax-mirror
filter: brightness(0.5)

/* 此处调节字体大小
.top .title font{
font-size: 7em;
}
*/
.cover-wrapper .cover-body .title {
font-size: 7em;
}
.top .title span{
transition: 0.5s;
}
.top .title:hover span:nth-child(1){
margin-right: 10px;
}
.top .title:hover span:nth-child(2){
margin-left: 10px;
}
.top .title:hover span{
color: #fff;
text-shadow: 0 0 10px #fff,
0 0 20px #fff,
0 0 40px #fff,
0 0 80px #fff,
0 0 120px #fff,
0 0 160px #fff;
}
blog\custom.js
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
var binft = function (r) {
var isTransparent = true;
function getRandomColor() {
if(isTransparent){
isTransparent = false;
//此处修改字体颜色,最后的 0 和 1 不要改
return "rgba(255,255,255,0)"
}else{
isTransparent = true;
return "rgba(255,255,255,1)"
}
}
function n(r) {
for (var n = document.createDocumentFragment(), i = 0; r > i; i++) {
var oneword = document.createElement("span");
oneword.textContent = "_"; // 此处是末尾字符,如果想用光标样式可以改为"|"
oneword.style.color = getRandomColor();
n.appendChild(oneword);
}
return n
}
function i() {
var t = wordList[c.skillI];
c.step ? c.step-- : (c.step = refreshDelayTime, c.prefixP < l.length ? (c.prefixP >= 0 && (c.text += l[c.prefixP]), c.prefixP++) : "forward" === c.direction ? c.skillP < t.length ? (c.text += t[c.skillP], c.skillP++) : c.delay ? c.delay-- : (c.direction = "backward", c.delay = showTotalWordDelayTime) : c.skillP > 0 ? (c.text = c.text.slice(0, -1), c.skillP--) : (c.skillI = (c.skillI + 1) % wordList.length, c.direction = "forward")), r.textContent = c.text, r.appendChild(n(c.prefixP < l.length ? Math.min(maxLength, maxLength + c.prefixP) : Math.min(maxLength, t.length - c.skillP))), setTimeout(i, d)
}
var l = "",
//此处改成你自己的诗词
wordList = [
//例:
"最是人间留不住,朱颜辞镜花辞树. ——王国维《蝶恋花》",
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
].map(function (r) {
return r + ""
}),
showTotalWordDelayTime = 2,
refreshDelayTime = 1,
maxLength = 1,
d = 75,
c = {
text: "",
prefixP: -maxLength,
skillI: 0,
skillP: 0,
direction: "forward",
delay: showTotalWordDelayTime,
step: refreshDelayTime
};
i()
};
binft(document.getElementById('binft'));

// 添加打开背景图片的函数
function openCurrentBgImage() {
const bgElement = document.querySelector('.parallax-mirror img');
if (bgElement && bgElement.src) {
window.open(bgElement.src, '_blank');
} else {
console.log('未找到背景图片');
}
}

3 CDN配置

CDN的配置能让国内访问网站更加稳定快速,具体关于CDN请点击这里

3.1 注册域名

  • 我用的是腾讯云,如果使用其他的运营商也类似。

首先注册一个自己的域名,推荐.cn作为后缀,价格不贵。或者选择六位数字.xyz,貌似是目前最便宜的域名。

按照指引完成域名注册,第一次注册要实名认证

3.2 域名解析到github

  • 进入 腾讯云 > 控制台 > 我的域名 > 解析

  • 添加解析,将子域名解析到你的github pages
操作示例
操作示例

主机记录可以简单理解为子域名,比如你注册的域名是example.com,添加了主机记录为zzz后,可以用zzz.example.com访问你的网站。记录值就是你的域名指向的ip或其他域名,当记录值为其他域名,如yourname.github.io时,请使用CNAME记录类型。

  • 进入 github > 你的仓库 > Setting > Pages > Custom domain 改成自己的子域名

出现 DNS check successful 时说明更改成功,其本质就是在仓库根目录创建一个CNAME文件。

这时使用子域名就可以访问我们的网站了。

注意每次执行 hexo d 都会覆盖CNAME文件导致更改失效!

3.3 CDN的配置

这里我选择初七云作为运营商。便宜,而且部分服务器在国外,不用备案。

推荐购买不用备案亚太加速

购买页面
购买页面

购买成功后,进入控制台 > 产品与服务 > SCDN安全内容分发 > 操作 > 登录面板 ,进入初星盾。

要是显示待开通,请联系客服帮你开通。

进入初星盾后,点击CDN加速 > 我的网站 > 添加网站,按下图操作。加速域名可以选择blog.你的域名,即新的子域名;源站地址填写zzz.你的域名,即3.2中创建的子域名;回源主机名选择跟随源站

image

点击保存后,你会得到一串CDN提供的CNAME值,你可以理解为CDN的域名。随后打开腾讯云控制台,进入域名解析页,添加主机记录为blog的解析,记录类型CNAME,值为CDN提供的那串域名。随后返回初星盾,直到网站状态显示成功。(这里我差不多等了15分钟)

最后进入初星盾,点击网站列表右侧的管理,进入HTTPS界面,选择免费申请证书

证书申请入口
证书申请入口

根据提升完成证书申请,最后你的网站就可以在blog.你的域名上打开啦!

放一张ITDOG上的测试图:

至此所有基础配置完成

4 杂项配置

4.1 解决hexo clean导致配置丢失

hexo框架需要每次数据更新时执行hexo g重新覆盖blog\public文件夹。多次的执行会让生成的静态网页发生不知名的错误,这时候就要用hexo clean命令先删除public文件夹,再执行hexo g重新部署。

hexo clean命令会彻底删除文件夹中的一切信息,而hexo d会把整个public文件夹中的东西覆盖推送到github。这时候,魔改配置文件custom.js和部署CDN的CNAME文件都会被覆盖导致丢失。

  • 解决方案:把这两个文件都放在blog/source文件夹下

source文件夹下的文件会被hexo g自动生成到public文件夹下。

4.2 更好的CDN配置(初七云限定)

对境内和境外流量分开解析,取消工具域名zzz.xinghenluyus.cn,境外流量直达github page,境内流量导入加速CDN,CDN回源直接填写blog.xinghenluyus.cn即可。
因为初七云CDN服务器在海外,但是国内流量使用代理不能正常访问,会极大不方便。

分线路解析
分线路解析
更多问题欢迎在评论区探讨!

评论