如何在 Jekyll 中只显示特定的 post?

How to show only specific post in Jekyll?

我正在尝试使用 Jekyll 创建一个简单的单页网站。该网站将进一步用于创建 post,例如 content blocks

但在我的 Jekyll 站点中,我只想显示某些 post 而不是所有可用的。

如何在不使用 forif 过滤 post 的情况下获得特定的 post?这可能吗?


编辑 1:

为了让我得到任何特定的 post,我使用以下方式:

{% for post in site.posts %}
   {% if post.title = "my title" %}
      <h3> {% post.title %} </h3>
      blablabla
   {% endif %}
{% endfor %}

那么,有没有人找到一种不使用 for 而用 "my title" 显示特定 post 的简单方法?

任何post在他的前面的published: false都不会出现在{% for post in site.posts %}循环中。

但我不明白你想摆脱 forif

只需将 published: false 放在您的 YAML 前面, 运行 在您的代码中没有 if 语句的循环。 published: false 的帖子将不会显示。