Jekyll 如何在杰基尔获得ints?
我正在尝试创建一个博客,我想创建与每次for循环运行时对应的id标记(例如#section_1、#section_2、#section_(插入变量))Jekyll 如何在杰基尔获得ints?,jekyll,Jekyll,我正在尝试创建一个博客,我想创建与每次for循环运行时对应的id标记(例如#section_1、#section_2、#section_(插入变量)) 在Jekyll中有什么方法可以做到这一点吗?这应该会产生您想要的结果: {% assign indices = "1|2|3" | split: "|" %} {% for index in indices %} <div id="{{ index }}">This is div {{ index }}</div>
在Jekyll中有什么方法可以做到这一点吗?这应该会产生您想要的结果:
{% assign indices = "1|2|3" | split: "|" %}
{% for index in indices %}
<div id="{{ index }}">This is div {{ index }}</div>
{% endfor %}
{%assign index=“1 | 2 | 3”| split:|“%”
{索引%中的索引为%}
这是div{{index}
{%endfor%}
您必须提前知道要创建多少节,并将每个ID添加到第一行的1 | 2 | 3
位。使用
菜单部分:
<ul>
{% for posts in site.posts %}
<li><a href="#section_{{ forloop.index }}">{{ post.title }}</a></li>
{% endfor %}
</ul>
{site.posts%%中的帖子占%s}
{%endfor%}
内容部分:
{% for posts in site.posts %}
<h2 id="section_{{ forloop.index }}">{{ post.title }}</h2>
{{ post.content }}
{% endfor %}
{%用于site.posts%}
{{post.title}}
{{post.content}}
{%endfor%}
这真的很模糊。你能再解释一下吗。输入是什么?期望的输出是什么?我正在尝试这样做:每个部分都是一篇博客文章