Jekyll 分页索引未找到。

3

首先,我正在使用Jekyll 3.5.1。

我已经在我的Jekyll配置中启用了分页,并将以下内容添加到了我的_config.yml文件中:

 #pagination
 paginate: 5
 paginate_path: "blog/page:num"

在我的根目录下,我创建了一个名为“blog”的文件夹,并在其中创建了一个“index.html”文件。然而,当我尝试提供该文件时,我收到警告,说无法找到“index.html”文件的分页。
我也尝试过只使用根目录下的index.html文件,但那也没有成功。
在这里您可以看到github repo,以防有所帮助。
我已经尝试过调整paginate_path和index.html文件。任何帮助将不胜感激!
具体错误消息如下:
Pagination: Pagination is enabled, but I couldn't find an index.html page to use as the pagination template. Skipping pagination.

任何帮助都将不胜感激。
2个回答

0
一个导致这个错误信息的原因是:括号编辑器的“美化”命令在执行时无法识别 YAML 代码,因此它会看到 index.html 文件中的顶部 YAML。
---
layout: default
title: Jekyll Title
---

...并将这4行转换为一条连续的线:

--- layout: default  title: Jekyll Themes ---

Jekyll 返回错误消息:

分页:已启用分页,但找不到用作分页模板的 index.html 页面。跳过分页。


0

index.html 不能为空。分页模板文件(由 pagination_path 引用)应包含生成带有文章列表的每个页面的代码,如docs建议的那样,创建 blog/index.html

---
layout: default
title: My Blog
---

<!-- This loops through the paginated posts -->
{% for post in paginator.posts %}
  <h1><a href="{{ post.url }}">{{ post.title }}</a></h1>
  <p class="author">
    <span class="date">{{ post.date }}</span>
  </p>
  <div class="content">
    {{ post.content }}
  </div>
{% endfor %}

<!-- Pagination links -->
<div class="pagination">
  {% if paginator.previous_page %}
    <a href="{{ paginator.previous_page_path }}" class="previous">Previous</a>
  {% else %}
    <span class="previous">Previous</span>
  {% endif %}
  <span class="page_number ">Page: {{ paginator.page }} of {{ paginator.total_pages }}</span>
  {% if paginator.next_page %}
    <a href="{{ paginator.next_page_path }}" class="next">Next</a>
  {% else %}
    <span class="next ">Next</span>
  {% endif %}
</div>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接