litten / hexo-theme-yilia

一个简洁优雅的hexo主题 A simple and elegant theme for hexo.
http://litten.me/
8.36k stars 2.41k forks source link

windows 平台下 http://localhost:4000/.本地访问出错,求解决方法 #370

Open yiihxie opened 7 years ago

yiihxie commented 7 years ago

在执行hexo s的时候不会报错,但是访问http://localhost:4000/.时就会出现以下错误。

$ hexo s
INFO  Start processing
INFO  Hexo is running at http://localhost:4000/. Press Ctrl+C to stop.
Unhandled rejection TypeError: D:\hexo\themes\yilia\layout\layout.ejs:9
    7|     </div>
    8|     <div class="mid-col" q-class="show:isShow,hide:isShow|isFalse">
 >> 9|       <%- partial('_partial/mobile-nav', null, {cache: !config.relative_link}) %>
    10|       <div id="wrapper" class="body-wrap">
    11|         <div class="menu-l">
    12|           <div class="canvas-wrap">

D:\hexo\themes\yilia\layout\_partial\mobile-nav.ejs:22
    20|                                         <li><a href="<%- url_for(theme.menu[i]) %>"><%= i %></a></li>
    21|                         <%}%>
 >> 22|                         <% if (theme.smart_menu.innerArchive) { %>
    23|                                 <li><a href="/archives/"><%= theme.smart_menu.innerArchive %></a></li>
    24|                         <% } %>
    25|                                 </ul>

Cannot read property 'innerArchive' of undefined
    at eval (eval at <anonymous> (D:\hexo\node_modules\ejs\lib\ejs.js:242:14), <anonymous>:30:1052)
    at eval (eval at <anonymous> (D:\hexo\node_modules\ejs\lib\ejs.js:242:14), <anonymous>:30:1746)
    at D:\hexo\node_modules\ejs\lib\ejs.js:255:15
    at _compiledSync (D:\hexo\node_modules\hexo\lib\theme\view.js:122:20)
    at View.renderSync (D:\hexo\node_modules\hexo\lib\theme\view.js:50:21)
    at D:\hexo\node_modules\hexo\lib\plugins\helper\partial.js:38:21
    at Object.fragmentCache (D:\hexo\node_modules\hexo\lib\plugins\helper\fragment_cache.js:9:30)
    at Object.wrapper [as fragment_cache] (D:\hexo\node_modules\lodash\lodash.js:4994:19)
    at Object.partial (D:\hexo\node_modules\hexo\lib\plugins\helper\partial.js:37:19)
    at Object.wrapper (D:\hexo\node_modules\lodash\lodash.js:4994:19)
    at eval (eval at <anonymous> (D:\hexo\node_modules\ejs\lib\ejs.js:242:14), <anonymous>:30:443)
    at eval (eval at <anonymous> (D:\hexo\node_modules\ejs\lib\ejs.js:242:14), <anonymous>:30:1229)
    at D:\hexo\node_modules\ejs\lib\ejs.js:255:15
    at _compiled (D:\hexo\node_modules\hexo\lib\theme\view.js:127:30)
    at View.render (D:\hexo\node_modules\hexo\lib\theme\view.js:29:15)
    at D:\hexo\node_modules\hexo\lib\theme\view.js:40:23
    at tryCatcher (D:\hexo\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (D:\hexo\node_modules\bluebird\js\release\promise.js:510:31)
    at Promise._settlePromise (D:\hexo\node_modules\bluebird\js\release\promise.js:567:18)
    at Promise._settlePromise0 (D:\hexo\node_modules\bluebird\js\release\promise.js:612:10)
    at Promise._settlePromises (D:\hexo\node_modules\bluebird\js\release\promise.js:691:18)
    at Async._drainQueue (D:\hexo\node_modules\bluebird\js\release\async.js:138:16)
mrpsweet commented 7 years ago

建议 git pull 一下主题

yiihxie commented 7 years ago

@mrpsweet 我已经pull了,但是无法打开,在本地打开localhost:4000的时候就出现了上面的错误。

litten commented 7 years ago

应该是配置问题,检查下yilia目录下的_config.yml里,有没有以下几个字段:

smart_menu:
  innerArchive: '所有文章'
  friends: '友链'
  aboutme: '关于我'

参考

Xing-Chuan commented 7 years ago

@yiihxie clone一份新的主题,把配置文件替换下 个人建议,供参考

daimingzhong commented 6 years ago

我写过一个脑残配置,引起了这个问题:

menu:
  HomePage: /
  : /tags/Tool/    (这里少一个名字)
ranying666 commented 5 years ago

搞了一上午终于找到原因了,因为在windows平台下编辑文件会包括特殊换行符导致只要修改了原配置文件都会出现这个问题。解决办法:在git-bash中编辑_config.yml等文件一点问题没有。 给我点赞~(≧▽≦)/~

xiaoxinne commented 4 years ago

您好,我在windows平台下也遇到此问题。现在_config.yml配置完全按照最新的配置修改的。这个应该怎么解决呢?

xiaoxinne commented 4 years ago

您好,我在窗口平台下也遇到此问题。现在_config.yml配置完全按照最新的配置修改的。这个应该怎么解决呢?

只要我一修改再保存,(添加一个空格再删除这个空格,然后保存)就会出现以上的错误。