我有一个文件夹,里面有很多 Markdown 文件,这些文件是页面。我想在我的标题中列出所有这些链接。我怎样才能在 Jekyll 中做到这一点?
您可以使用集合对象并对其进行迭代。
如果包含 html 页面的文件夹名为
_articles
:
_config.yml
中定义一个集合,例如:collections:
articles:
output: true # to make jekyll generate html pages
{% for article in site.articles %}
<a href="{{ article.url }}"> link to article </a>
{% endfor %}
您可以在此处阅读有关集合的更多信息:https://jekyllrb.com/docs/collections/