2013-11-15 70 views
1

我今天晚上为my website添加了分页,我遇到了现在我已经破坏了整个网站的问题。发布建设Jekyll博客文章页面和编辑

我对文件使用标准的Jekyll目录结构。对于我的网站,我希望索引页面关于我,然后点击/blog页面查看我的博客。所以我有index.md是通过主页。然后我有一个页面blog.html成为博客页面。我曾经使用{% for post in site.posts limit: 10 %}工作,并根据最新文档如何建议循环并打开,切换到{% for post in paginator.posts %}。在我的_config.yml文件中,我有:

paginate: 10 
paginate_path: "blog/page:num" 
permalink: /blog/:year/:month/:day/:title.html 

我希望分页为/blog/page2.html。我不确定我配置错了什么。这里是我的整个blog.html页面:

--- 
title: Blog 
layout: default 
permalink: /blog/index.html 
--- 

{% for post in paginator.posts %} 
<div class="row"> 
    <div class="col-lg-12"> 
     {% if post.layout contains "link" %} 
     <h4><a href="{{post.url}}"><i class="icon-link"></i>&nbsp;{{post.title}}</a></h4> 
     {% else %} 
     <h4><a href="{{post.url}}">{{post.title}}</a></h4> 
     {% endif %} 
     <small>{{post.date | date: "%m/%d/%Y"}}</small> 
     <div class="post-content-truncate"> 
      {% if post.content contains "<!-- more -->" %} 
       {{ post.content | split:"<!-- more -->" | first % }} 
       <a href="{{post.url}}">Read full article...</a> 
      {% else %} 
       {{ post.content }} 
      {% endif %} 
     </div> 
    </div> 
</div> 
{% endfor %} 

{% if paginator.total_pages > 1 %} 
<div class="row"> 
    <div class="col-lg-12"> 
      <ul class="pagination"> 
       {% if paginator.previous_page %} 
        <li><a href="{{ paginator.previous_page_path | prepend: site.baseurl | replace: '//', '/' }}">&laquo; Prev</a></li> 
       {% else %} 
        <span>&laquo; Prev</span> 
       {% endif %} 

       {% for page in (1..paginator.total_pages) %} 
        {% if page == paginator.page %} 
         <li><em>{{ page }}</em></li> 
        {% elsif page == 1 %} 
         <li><a href="{{ '/index.html' | prepend: site.baseurl | replace: '//', '/' }}">{{ page }}</a></li> 
        {% else %} 
         <li><a href="{{ site.paginate_path | prepend: site.baseurl | replace: '//', '/' | replace: ':num', page }}">{{ page }}</a></li> 
        {% endif %} 
       {% endfor %} 

       {% if paginator.next_page %} 
        <li><a href="{{ paginator.next_page_path | prepend: site.baseurl | replace: '//', '/' }}">Next &raquo;</a></li> 
       {% else %} 
        <li><span>Next &raquo;</span></li> 
       {% endif %} 
      </ul> 
    </div> 
</div> 
{% endif %} 

任何想法,我要去哪里错了?

回答

2

这个问题实际上是两个问题:

  1. 我用的是哲基尔的旧版本。一旦我升级到最新版本,它几乎可以工作。
  2. 我不得不把我的/blog.html文件到/blog/index.html

一旦我做了它的工作这两个步骤。

相关问题