【问题标题】:Jekyll Pagination Index not found找不到 Jekyll 分页索引
【发布时间】:2017-08-17 16:28:27
【问题描述】:

首先,我使用的是 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.

任何帮助将不胜感激。

【问题讨论】:

    标签: pagination jekyll


    【解决方案1】:

    index.hmtl 不能为空。分页模板文件(由paginatin_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>
    

    【讨论】:

      【解决方案2】:

      此错误消息的一个原因:括号编辑器“美化器”命令在执行时无法识别 YAML 代码,因此它会看到 index.html 文件的顶部 YAML:

      ---
      layout: default
      title: Jekyll Title
      ---
      

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

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

      Jekyll 以错误消息响应:

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

      【讨论】:

        猜你喜欢
        • 2012-04-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-04-13
        • 2016-01-14
        相关资源
        最近更新 更多