我正在尝试使用Hexo来创建我自己的主题;我遵循本教程:http://www.codeblocq.com/2016/03/Create-an-Hexo-Theme-Part-1-Index/,但是忽略了引导部分(不需要引导ATM机),并且我遇到了两个错误,我不知道它的来源/s。
当我尝试在教程的“阅读更多”部分之后运行"hexo generate“时,出现了错误。我发现了这个:https://github.com/hexojs/hexo/issues/1785,但它不是我的语言。
这是我的主题_config.yml
menu:
Home: /
Archives: /archives
title: Hello Hexo
author: BH0
# Read More text
excerpt_link: Read Morelayout.ejs
<html>
<!-- Head tag -->
<%- partial('_partial/head') %>
<body>
<!-- Menu -->
<%- partial('_partial/menu') %>
<div class="container">
<!-- Blog Header: title and subtitle -->
<%- partial('_partial/header') %>
<div class="row">
<!-- Main Content -->
<div class="col-sm-8 blog-main">
<%- body %>
</div>
<!-- Sidebar -->
<div class="col-sm-3 col-sm-offset-1 blog-sidebar">
<%- partial('_partial/sidebar') %>
</div>
</div>
</div>
<!-- Footer -->
<%- partial('_partial/footer') %>
<!-- After footer scripts -->
<%- partial('_partial/after-footer') %>
</body>
</html>index.ejs
<% page.posts.each(function(item) { %>
<%- partial('_partial/article-excerpt', {item: item}) %>
<% }); %>错误/错误是:
$ hexo generate
Unhandled rejection TypeError: C:\Users\User\hexo_blog\username.github.io\themes\mytheme\layout\index.ejs:1
>> 1| <% page.posts.each(function(item) { %>
2| <%- partial('_partial/article-excerpt', {item: item}) %>
3| <% }); %>
4|
Cannot read property 'each' of undefined 谢谢,任何帮助都很感激。告诉我是否还需要更多的信息。
发布于 2017-07-24 00:52:07
如本教程的注释部分所述:http://www.codeblocq.com/2016/03/Create-an-Hexo-Theme-Part-1-Index/
“这个错误是正常的,并不妨碍您运行博客的索引页。原因是您还没有创建其余的页面,因此,正如在”Hexo >页面类型基础“部分中所解释的那样,hexo将使用index.ejs作为所有页面(包括post详细信息页)的默认设置。问题是,并不是所有页面都有page.posts变量。
我想我很担心,因为错误/警告出现在红色(我与错误相关),而不是橙色/黄色(我与警告相关)。
https://stackoverflow.com/questions/45241822
复制相似问题