【Hexo】搭建博客时遇到的问题

一篇问题汇总

文件上传到GitHub时大小写改变

这个修补方法我还不知道怎样才能一劳永逸

这里第二个步骤一般可以跳过

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
1.修改文件:
cd blog/.deploy_git
vi .git/config
将ignorecase=true改为ignorecase=false

2.删除xxx.github.io中的文件并提交:
git rm -r *
git commit -m "clean all files"
git push

3.Hexo再次生成及部署:
cd ..
hexo clean
hexo g
hexo d

网页访问人数不显示

看了一下,是不蒜子那边出了域名的问题,改一下网址即可

我们找到主题文件夹,如我的主题是yelee

找到这个文件打开并修改它~/yelee/layout/_partial/after-footer.ejs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<% if (theme.github_widget){ %>
<%- js('js/GithubRepoWidget') %>
<% } %>
<script data-main="<%-config.root%>js/main.js" src="<%- theme.CDN.require %>"></script>
<%- partial('_partial/background') %>
<%- partial('comments/count-comment') %>
<%- partial('google-analytics') %>
<% if (theme.mathjax){ %>
<%- partial('mathjax') %>
<% } %>
<%- partial('scrolling-button') %>
<%- partial('open-in-new-tab', {
global: theme.open_in_new.global
}) %>
<%- partial('tab-title-change') %>
<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
</script>

只需把原有的:

1
<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

域名改成如下即可:

1
<script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

ERROR post.ejs

在使用hexo g时出现以下错误

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
ERROR E:\Blog\themes\yelee\layout\post.ejs:1
>> 1| <%- partial('_partial/article', {post: page, index: false}) %>

E:\Blog\themes\yelee\layout\_partial\article.ejs:17
15| <% if (!index){ %>
16| <div class="article-info article-info-post">
>> 17| <%- partial('post/category') %>
18| <%- partial('post/tag') %>
19| <div class="clearfix"></div>
20| </div>

E:\Blog\themes\yelee\layout\_partial\post\category.ejs:3
1| <% if (post.categories && post.categories.length){ %>
2| <div class="article-category tagcloud">
>> 3| <%- list_categories(post.categories, {
4| show_count: false,
5| class: 'article-category',
6| style: 'none',

#<Object> is not a function
TypeError: E:\Blog\themes\yelee\layout\post.ejs:1
>> 1| <%- partial('_partial/article', {post: page, index: false}) %>

E:\Blog\themes\yelee\layout\_partial\article.ejs:17
15| <% if (!index){ %>
16| <div class="article-info article-info-post">
>> 17| <%- partial('post/category') %>
18| <%- partial('post/tag') %>
19| <div class="clearfix"></div>
20| </div>

E:\Blog\themes\yelee\layout\_partial\post\category.ejs:3
1| <% if (post.categories && post.categories.length){ %>
2| <div class="article-category tagcloud">
>> 3| <%- list_categories(post.categories, {
4| show_count: false,
5| class: 'article-category',
6| style: 'none',

#<Object> is not a function
at Array.find (<anonymous>)
at prepareQuery (E:\Blog\node_modules\hexo\lib\plugins\helper\list_categories.js:30:23)
at flatList (E:\Blog\node_modules\hexo\lib\plugins\helper\list_categories.js:81:5)
at Object.listCategoriesHelper (E:\Blog\node_modules\hexo\lib\plugins\helper\list_categories.js:105:10)
at eval (eval at compile (E:\Blog\node_modules\ejs\lib\ejs.js:633:12), <anonymous>:12:17)
at returnedFn (E:\Blog\node_modules\ejs\lib\ejs.js:668:17)
at Theme._View.View._compiledSync.locals [as _compiledSync] (E:\Blog\node_modules\hexo\lib\theme\view.js:119:22)
at Theme._View.View.View.renderSync (E:\Blog\node_modules\hexo\lib\theme\view.js:48:23)
at Object.partial (E:\Blog\node_modules\hexo\lib\plugins\helper\partial.js:34:15)
at eval (eval at compile (E:\Blog\node_modules\ejs\lib\ejs.js:633:12), <anonymous>:41:17)
at returnedFn (E:\Blog\node_modules\ejs\lib\ejs.js:668:17)
at Theme._View.View._compiledSync.locals [as _compiledSync] (E:\Blog\node_modules\hexo\lib\theme\view.js:119:22)
at Theme._View.View.View.renderSync (E:\Blog\node_modules\hexo\lib\theme\view.js:48:23)
at Object.partial (E:\Blog\node_modules\hexo\lib\plugins\helper\partial.js:34:15)
at eval (eval at compile (E:\Blog\node_modules\ejs\lib\ejs.js:633:12), <anonymous>:9:17)
at returnedFn (E:\Blog\node_modules\ejs\lib\ejs.js:668:17)
at Theme._View.View._compiled.locals [as _compiled] (E:\Blog\node_modules\hexo\lib\theme\view.js:123:48)
at Theme._View.View.View.render (E:\Blog\node_modules\hexo\lib\theme\view.js:29:15)
at E:\Blog\node_modules\hexo\lib\hexo\index.js:349:21
at tryCatcher (E:\Blog\node_modules\bluebird\js\release\util.js:16:23)
at E:\Blog\node_modules\bluebird\js\release\method.js:15:34
at RouteStream._read (E:\Blog\node_modules\hexo\lib\hexo\router.js:123:3)

最后排查是因为自己随便建的文件夹里面【在source文件夹里】放了layout为post的md文本

Connection reset by 52.74.223.119 port 22

错误过程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
VZZ@LAPTOP-1LKROVMM MINGW64 /e/Blog/source/_posts
$ hexo d
INFO Deploying: git
INFO Clearing .deploy_git folder...
INFO Copying files from public folder...
INFO Copying files from extend dirs...
[master f3a5e33] Site updated: 2019-10-03 09:04:42
4 files changed, 21 insertions(+), 14 deletions(-)
Connection reset by 52.74.223.119 port 22
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
FATAL Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html
Error: Spawn failed
at ChildProcess.<anonymous> (E:\Blog\node_modules\hexo-util\lib\spawn.js:52:19)
at ChildProcess.emit (events.js:198:13)
at ChildProcess.cp.emit (E:\Blog\node_modules\cross-spawn\lib\enoent.js:40:29)
at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)

这个需要自己设置一下防火墙,步骤如下

按下 win + r 键打开运行窗口,输入 control 打开控制面板

在右上角输入防火墙,找到Windows Defender 防火墙,点击进入

点击高级设置,在里面点击入站规则。在右边找到新建规则,点击它

以下是新建过程

1
2
3
4
5
6
7
要创建的规则类型                           --> 端口
此协议应用于 TCP 还是 UDP? --> TCP
此规则应用于所有本地端口还是特定的本地端口? --> 特定本地端口(S): 22
连接符合指定条件时应该进行什么操作? --> 允许连接
何时应用该规则? --> [全选 -- 域;专用;公用]
名称(N): --> 22
描述(可选)(D): --> Connection reset by 52.74.223.119 port 22

这也可能是 md 文本名称的最后有一个空格从而导致的错误

unknown block tag

写一道逆向题解时报的错误

1
2
3
4
FATAL Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html
Nunjucks Error: [Line 33, Column 87] unknown block tag: s
===== Context Dump =====
=== (line number probably different from source) ===

这里是因为它会把

1
{%s}

这个东西解释成标签,暂且不知道除了将其放入代码框里还有什么别的办法

主页面无法正常加载

发现本地和 github 上面的博客都不能正常加载了,于是看了看控制台,发现 js 加载出现了问题,如下:

1
2
3
指向“https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js”的 <script> 加载失败
指向“https://cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js”的 <script> 加载失败。
指向“https://cdn.bootcss.com/require.js/2.2.0/require.min.js”的 <script> 加载失败。

访问一下,发现是cdn.bootcss.com的证书出现了问题导致无法正常访问,这时我们只需要把他换个源就好

即把cdn.bootcss.com换成cdnjs.cloudflare.com/ajax/libs,操作如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
PS F:\Blog\themes\yelee> findstr.exe /s "cdn.boot" *
layout\_partial\head.ejs: <link href="//cdn.bootcss.com/pace/1.0.2/themes/<%= theme.progressBar.color || 'blue'%>/pace-theme-<%= theme.progressBar.type || 'minimal'%>.css" rel="stylesheet">
source\css\_partial\customise\social-icon.styl: background url(//cdn.bootcss.com/logos/0.2.0/github-octocat.svg) no-repeat white
source\css\_partial\customise\social-icon.styl: background url(//cdn.bootcss.com/logos/0.2.0/codepen-icon.svg) no-repeat black
_config.yml: jquery: //cdn.bootcss.com/jquery/2.2.4/jquery.min.js
_config.yml: require: //cdn.bootcss.com/require.js/2.2.0/require.min.js
_config.yml: fontawesome: //cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css
_config.yml: fancybox_js: //cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.js
_config.yml: fancybox_css: //cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.css
_config.yml: animate_css: //cdn.bootcss.com/animate.css/3.5.1/animate.min.css
_config.yml: jquery_ui_js: //cdn.bootcss.com/jqueryui/1.10.4/jquery-ui.min.js
_config.yml: jquery_ui_css: //cdn.bootcss.com/jqueryui/1.10.4/css/jquery-ui.min.css
_config.yml: pace_js: //cdn.bootcss.com/pace/1.0.2/pace.min.js
_config.yml: clipboard: //cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js
_config.yml: mathjax: //cdn.bootcss.com/mathjax/2.6.1/MathJax.js
_config.yml: scrollreveal: //cdn.bootcss.com/scrollReveal.js/3.1.4/scrollreveal.min.js

之后挨个换一遍就 ok 了

文章目录
  1. 1. 文件上传到GitHub时大小写改变
  2. 2. 网页访问人数不显示
  3. 3. ERROR post.ejs
  4. 4. Connection reset by 52.74.223.119 port 22
  5. 5. unknown block tag
  6. 6. 主页面无法正常加载
|