Github 如何在Jekyll中显示特定帖子?
我想使用杰基尔作为一个CMS本质上,所以我想从一个帖子的内容,并显示在我的网站的特定区域Github 如何在Jekyll中显示特定帖子?,github,content-management-system,yaml,jekyll,Github,Content Management System,Yaml,Jekyll,我想使用杰基尔作为一个CMS本质上,所以我想从一个帖子的内容,并显示在我的网站的特定区域 {% for post in site.posts %} {{ post.content }} {% endfor %} 这将显示所有帖子中的所有内容,但是我希望一次只获取一篇帖子中的内容。我是Jekyll的新手,所以我不确定我是否应该将YAML front matter添加到我的帖子中,并在网站中以标题为post.content的for post作为目标 谢谢 我知道了,抱歉我过早地发布了 答
{% for post in site.posts %}
{{ post.content }}
{% endfor %}
这将显示所有帖子中的所有内容,但是我希望一次只获取一篇帖子中的内容。我是Jekyll的新手,所以我不确定我是否应该将YAML front matter添加到我的帖子中,并在网站中以标题为post.content的for post作为目标
谢谢 我知道了,抱歉我过早地发布了
答案是使用YAML front matter在您的帖子中添加一个类别,然后在您的include文件中使用:
{% for post in site.categories.CATEGORYNAMEHERE %}
{{ post.content }}
{% endfor %}
{%assign thepost=site.posts |其中:slug,post_slug%}
{%用于post%中的post}
{{post.content}}
{%endfor%}如果只想显示一篇文章,则此操作无效。