gpt4 book ai didi

ruby - 在 Jekyll 中,site.posts 不返回任何内容

转载 作者:太空宇宙 更新时间:2023-11-03 16:33:08 24 4
gpt4 key购买 nike

我用 Jekyll 写博客。在我的 source/index.html(我在 _config.yml 中重新配置了路径)我写了:

{{ site.posts }} 

但是当我编译它时,它没有给出任何结果。我确定我有帖子,它们已编译并按预期工作。

我不知道从哪里开始排除故障,有没有其他人遇到过这样的问题?

最佳答案

site.post 返回液化的 Jekyll::Post 对象数组。您可以通过简单地编写来检查帖子数:

{{ site.posts.size }} 

你可以遍历它们:

<ul>
{% for post in site.posts %}
<li class="post">
<h1><a href="{{ post.url }}">{{ post.title }}</a></h1>
</li>
{% endfor %}
</ul>

关于ruby - 在 Jekyll 中,site.posts 不返回任何内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12433095/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com