有没有办法从site.posts获取当前的帖子索引号?
{{site.posts | size}}是帖子的总数.
我需要的是{{site.posts.index}}或{{page.index}}.
解决方法
在for循环中,您可以通过两种方式获取当前项索引:
{% for post in site.posts %}{{ forloop.index }}{% endfor %} # will print 123...
要么
{% for post in site.posts %}{{ forloop.index0 }}{% endfor %} # will print 012...
你需要的是{{forloop.index}}