V-Vincen/hexo-theme-livemylife

Regarding the hexo live-my-life theme layout error

Reio0807 opened this issue · 8 comments

Hello Vincen!
I really loved this theme you created, but after I try to change this theme to my blog, the following error occurred:
err: TypeError: ~blog\themes\livemylife\layou
t\layout.ejs:5
3|
4|

5| <%- partial('_partial/head') %>
6|
7|
8|
May you inpect this issue and fix it? I really like this theme! ThankYou!

Hello Vincen!
I really loved this theme you created, but after I try to change this theme to my blog, the following error occurred:
err: TypeError: ~blog\themes\livemylife\layou
t\layout.ejs:5
3|
4|

5| <%- partial('_partial/head') %>
6|
7|
8|
May you inpect this issue and fix it? I really like this theme! ThankYou!

Can you speak Chinese?
我自己按照我之前写的文档再试了一遍,并没有出现你说的错误,你可不可以截张图给我看看。

dalao,我在尝试使用此主题时也出现了和楼上提出的一样的错误。。真心觉得这主题贼好看,请宁再排查修复下吧!

不好意思,上周工作有点忙 ,未能及时回复,请见谅。
今天我又重新按照我之前的文档再尝试了一遍,并没有出现两位所说的问题。我认为可能是因为我用的是Mac电脑的原因,所以我换了Windows的系统进行了尝试,但是重试后也没有出现任何问题。我个人觉得可能是两位的hexo版本的问题,两个可以尝试先全局升级hexo-cli。下面是我hexo的版本信息:

➜ blog git:(master) ✗ hexo -version
hexo: 4.2.1
hexo-cli: 4.2.0
os: Darwin 19.5.0 darwin x64
node: 12.16.3
v8: 7.8.279.23-node.35
uv: 1.34.2
zlib: 1.2.11
brotli: 1.0.7
ares: 1.16.0
modules: 72
nghttp2: 1.40.0
napi: 5
llhttp: 2.0.4
http_parser: 2.9.3
openssl: 1.1.1g
cldr: 36.1
icu: 66.1
tz: 2019c
unicode: 13.0

升级命令:npm i hexo-cli -g

还有就是,之前截图给我的错误信息不完整:

err: TypeError: ~blog\themes\livemylife\layou
t\layout.ejs:5
3|
4|
5| <%- partial('_partial/head') %>
6|
7|
8|

这里的错误信息只是说,第5行也就是 <%- partial('_partial/head') %> 有错误,但是 head 是一个文件,里面有很多内容。你截给我的内容下面,应该还会有指明具体,什么地方内容的错误。所以如果你们尝试hexo升级后,还无法解决这个错误的话。请把全部完整的错误信息截图给我。

hi,我的问题和他也是一样的layout.ejs:5,以下是控制台报错信息:

err: TypeError: /Users/liuxue/myBlog/themes/hexo-theme-livemylife-master/layout/layout.ejs:5
3|
4|

5| <%- partial('_partial/head') %>
6|
7|
8|

/Users/liuxue/myBlog/themes/hexo-theme-livemylife-master/layout/_partial/head.ejs:33
31|
32|

33| <% if (config.baidusitemap.baidu_push) { %>
34| <script>
35| (function() {
36| var bp = document.createElement('script');

Cannot read property 'baidu_push' of undefined
at eval (/Users/liuxue/myBlog/themes/hexo-theme-livemylife-master/layout/_partial/head.ejs:31:32)
at head (/Users/liuxue/myBlog/node_modules/ejs/lib/ejs.js:682:17)
at _View._compiledSync (/Users/liuxue/myBlog/node_modules/hexo/lib/theme/view.js:132:24)
at _View.renderSync (/Users/liuxue/myBlog/node_modules/hexo/lib/theme/view.js:59:25)
at Object.partial (/Users/liuxue/myBlog/node_modules/hexo/lib/plugins/helper/partial.js:34:15)
at eval (/Users/liuxue/myBlog/themes/hexo-theme-livemylife-master/layout/layout.ejs:10:17)
at layout (/Users/liuxue/myBlog/node_modules/ejs/lib/ejs.js:682:17)
at _View._compiled (/Users/liuxue/myBlog/node_modules/hexo/lib/theme/view.js:136:50)
at _View.render (/Users/liuxue/myBlog/node_modules/hexo/lib/theme/view.js:39:17)
at /Users/liuxue/myBlog/node_modules/hexo/lib/theme/view.js:51:25
at tryCatcher (/Users/liuxue/myBlog/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/liuxue/myBlog/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/Users/liuxue/myBlog/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/Users/liuxue/myBlog/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/Users/liuxue/myBlog/node_modules/bluebird/js/release/promise.js:729:18)
at _drainQueueStep (/Users/liuxue/myBlog/node_modules/bluebird/js/release/async.js:93:12)
at _drainQueue (/Users/liuxue/myBlog/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/Users/liuxue/myBlog/node_modules/bluebird/js/release/async.js:102:5)
at Immediate.Async.drainQueues [as _onImmediate] (/Users/liuxue/myBlog/node_modules/bluebird/js/release/async.js:15:14)
at processImmediate (internal/timers.js:456:21) {
path: '/Users/liuxue/myBlog/themes/hexo-theme-livemylife-master/layout/layout.ejs'
}
} Render HTML failed: index.html
Unhandled rejection TypeError: /Users/liuxue/myBlog/themes/hexo-theme-livemylife-master/layout/layout.ejs:5
3|
4|

5| <%- partial('_partial/head') %>
6|
7|
8|

/Users/liuxue/myBlog/themes/hexo-theme-livemylife-master/layout/_partial/head.ejs:33
31|
32|

33| <% if (config.baidusitemap.baidu_push) { %>
34| <script>
35| (function() {
36| var bp = document.createElement('script');

Cannot read property 'baidu_push' of undefined
at eval (/Users/liuxue/myBlog/themes/hexo-theme-livemylife-master/layout/_partial/head.ejs:31:32)
at head (/Users/liuxue/myBlog/node_modules/ejs/lib/ejs.js:682:17)
at _View._compiledSync (/Users/liuxue/myBlog/node_modules/hexo/lib/theme/view.js:132:24)
at _View.renderSync (/Users/liuxue/myBlog/node_modules/hexo/lib/theme/view.js:59:25)
at Object.partial (/Users/liuxue/myBlog/node_modules/hexo/lib/plugins/helper/partial.js:34:15)
at eval (/Users/liuxue/myBlog/themes/hexo-theme-livemylife-master/layout/layout.ejs:10:17)
at layout (/Users/liuxue/myBlog/node_modules/ejs/lib/ejs.js:682:17)
at _View._compiled (/Users/liuxue/myBlog/node_modules/hexo/lib/theme/view.js:136:50)
at _View.render (/Users/liuxue/myBlog/node_modules/hexo/lib/theme/view.js:39:17)
at /Users/liuxue/myBlog/node_modules/hexo/lib/theme/view.js:51:25
at tryCatcher (/Users/liuxue/myBlog/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/liuxue/myBlog/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/Users/liuxue/myBlog/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/Users/liuxue/myBlog/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/Users/liuxue/myBlog/node_modules/bluebird/js/release/promise.js:729:18)
at _drainQueueStep (/Users/liuxue/myBlog/node_modules/bluebird/js/release/async.js:93:12)
at _drainQueue (/Users/liuxue/myBlog/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/Users/liuxue/myBlog/node_modules/bluebird/js/release/async.js:102:5)
at Immediate.Async.drainQueues [as _onImmediate] (/Users/liuxue/myBlog/node_modules/bluebird/js/release/async.js:15:14)
at processImmediate (internal/timers.js:456:21)

首先感谢几位提出的问题。再这里也很抱歉,由于工作的原因,未能及时回复,还请见谅。
看了上楼截的具体错误信息,我已知道问题所在。

Cannot read property 'baidu_push' of undefined

这里的原因是hexo在生成页面的时候,未能读取到配置文件 _config.yml 中的 百度站点收录 baidu_push 配置属性。

## Baidusitemap
baidusitemap:
  path: baidusitemap.xml
  baidu_push: true

在我自测博客文档生成的时候,并没有出现这样的问题,至于为什么有些朋友出现了这样的错误,而有些朋友并没有出现这样的错误,这很可能是hexo的版本不同造成的原因(个人推测)。那么下面我对这个报错做了相应的修改。配置文件 _config.yml 修改如下:

## Baidusitemap
baidusitemap:
  path: baidusitemap.xml
baidu_push: true

同时也对 livemylife/layout/_partial/head.ejs 文件做了相应修改,修改如下:

33| <% if (config.baidu_push) { %>
34| <script>
35| (function() {
        ......
47| <% } %>

其实这段代码的功能是百度站点收录自动推送,如果不需要这个功能的朋友,也可以直接把上面我改动的这两段内容全部删除。修改好的内容我已提交到github上,大家可以重新拉取下后,再尝试博客能否生成。
最后如果大家对谷歌站点收录,百度站点收录这两个功能有兴趣的朋友可以参考我写的这篇文档:https://v-vincen.life/2020/07/21/Analytics-and-Sitemap-Settings/#Baidu-Sitemap-Settings
如还有什么问题,尽可留言,我会第一时间回复。
不便之处还请大家见谅,最后也万分感谢大家对我改编的主题的支持。

Vicent你好,我按照你的说法升级了hexo版本,也下载了你修改之后的压缩包,现在虽然能部署了,但是整个主题没有显示,如图:
image

=====================================================
然后我的hexo版本信息如图:
image

不知道这个新的情况是怎么回事,盲猜与layout源码有关,还请您排查下,肥肠感谢!

Vicent你好,我按照你的说法升级了hexo版本,也下载了你修改之后的压缩包,现在虽然能部署了,但是整个主题没有显示,如图:
image

=====================================================
然后我的hexo版本信息如图:
image

不知道这个新的情况是怎么回事,盲猜与layout源码有关,还请您排查下,肥肠感谢!

不好意思,节前工作比较忙,未能及时回复。上面的问题,我想问下,你本地调试的时候(hexo s),样式是否也是一样没有呈现出来,还有就是 _config.yml 配置文件中:

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://yoursite-url      # Note: don't forget to modify the CNAME file to your url
root: /
permalink: :year/:month/:day/:title/
permalink_defaults:

这段的 url 你是否配置正确了。你可以先确认下后再尝试下,如果确认后还是有问题的话。可以直接加我 qq:601521821@qq.com 联系我。回复的内容希望能够对你有帮助。