我怎样才能控制我最近的Jekyll帖子? 最近的职位 {site.posts%中的post为%s} &拉阔 {%endfor%}

我怎样才能控制我最近的Jekyll帖子? 最近的职位 {site.posts%中的post为%s} &拉阔 {%endfor%},jekyll,Jekyll,这是我所有文章的代码,我如何控制文章的数量,并在部分中显示10篇文章?这就是方法 <section id="article"> <h3>Recent posts</h3> <ul> {% for post in site.posts %} <li>&raquo; <a href="{{ post.url }}">{{ post.title }}</a></li>

这是我所有文章的代码,我如何控制文章的数量,并在部分中显示10篇文章?

这就是方法

  <section id="article">
  <h3>Recent posts</h3>
<ul>
    {% for post in site.posts %}
      <li>&raquo; <a href="{{ post.url }}">{{ post.title }}</a></li>
    {% endfor %}
  </ul>
</section>

最近的职位
    {站点中的帖子的百分比。帖子限制:10%}
  • {%endfor%}

试试这个。这段代码显示了10个最近发布的类似于最近发布的小部件

我会用另一种方式

<section id="article">
  <h3>Recent posts</h3>
  <ul>
    {% for post in site.posts limit:10 %}
      <li><a href="{{ post.url }}">
    {% endfor %}
  </ul>
</section>
{%用于站点中的帖子。帖子限制:1%}
{%if-forloop.last%}
  • {%endif%} {%endfor%}

    我已经包含了一个带有forloop.last的if逻辑标记,因此它将只显示最后一篇、最近一篇文章。由于我还包含了{limit:1},因此输出将仅为一篇文章。

    嗨,你知道为什么我的这篇文章的url包含
    %5c
    ,无法正确打开吗。你可以从我的主页上打开它,html文件是。
    <section id="article">
      <h3>Recent posts</h3>
      <ul>
        {% for post in site.posts limit:10 %}
          <li><a href="{{ post.url }}">
        {% endfor %}
      </ul>
    </section>
    
    {% for post in site.posts limit:1  %}
    {% if forloop.last %}
      <li>
        <a href="post-link" href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a>
      </li>
    {% endif %}
    {% endfor %}