如何在Jekyll中查找特定帖子的索引编号?

更新于
2026-10-03 20:44:54
0阅读来源:SEO资讯
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计173个文字,预计阅读时间需要1分钟。

如何从site.posts中获取当前帖子的索引?{{site.posts | size}}是帖子的总数。我需要的是{{site.posts.index}}或{{page.index}}。我想在每个帖子页面上显示一个计数器。例如:2026年第43期

有没有办法从site.posts获取当前的帖子索引号?

{{site.posts | size}}是帖子的总数.
我需要的是{{site.posts.index}}或{{page.index}}.

我想在每个帖子页面上显示一个计数器.示例:2654年第43期

在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}}

标签:帖

本文共计173个文字,预计阅读时间需要1分钟。

如何从site.posts中获取当前帖子的索引?{{site.posts | size}}是帖子的总数。我需要的是{{site.posts.index}}或{{page.index}}。我想在每个帖子页面上显示一个计数器。例如:2026年第43期

有没有办法从site.posts获取当前的帖子索引号?

{{site.posts | size}}是帖子的总数.
我需要的是{{site.posts.index}}或{{page.index}}.

我想在每个帖子页面上显示一个计数器.示例:2654年第43期

在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}}

标签:帖