Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jekyll 如何使用标记集合_Jekyll_Liquid - Fatal编程技术网

Jekyll 如何使用标记集合

Jekyll 如何使用标记集合,jekyll,liquid,Jekyll,Liquid,我收集了一些作者的作品 我想通过以下方式为我的帖子分配作者标签: {% assign author = site.authors | where: "title", page.author | first %} {% if author %} <a href="{{ author.url }}">{{ author.title }}</a> {% endif %} Frontmatter集合条目示例: --- title: Building date: 20

我收集了一些作者的作品

我想通过以下方式为我的帖子分配作者标签:

{% assign author = site.authors | where: "title", page.author | first %}
 {% if author %}
  <a href="{{ author.url }}">{{ author.title }}</a>
{% endif %}
Frontmatter集合条目示例:

---
title:  Building
date:   2017-01-11 16:22:51 +0100
author: Bob Baumeister
---

Content
---
title:  Bob Baumeister
twitter: bobby
---

Content
谢谢你的帮助。

试试

author: "Bob Baumeister"
更新
你能举一个作者输入的例子吗?这可能是由于使用了过滤器“first”,选择作者姓名中的第一个字符串,用一个页面示例更新问题。作者示例及其在数据文件中的条目@David:是的,我在上面添加了一些示例。@user3473628上面的示例对我有效,您试图替换哪个标题?@marcanuy它应该是指向“Bob Baumeister”中所有帖子所在列表的链接已列出。对我来说,它只适用于名字。示例:如果我只使用“Bob”,则在我的帖子中会显示一个链接。“Bob Baumeister”没有。谢谢你的提示。在我的帖子里试过了。但是不起作用。如果我只使用一个名字,比如
Bob
,它就行了。Bob Baumeister也能工作。只有鲍勃·鲍迈斯特(Bob Baumeister)不起作用……这是正确的方法。因为
page.author
被删除了,网站上的“标题”也被删除了。authors not我在authors集合中添加了另一个标签,比如
authors\u slug
,内容为
bob baumeister
,或者也可以删除“标题”吗?谢谢是的,您可以将
slug
过滤器应用于您想要的任何字符串,例如
{%assign slug=“Title With spaces”| slagify%}
<!-- Bob Bau => bob-bau -->
{% assign slug = page.author | slugify  %}

<!-- filter by the slugified title -->
{% assign author = site.authors | where: "title", slug | first%}
...
 - name: Bob Baumeister
   title: bob-baumeister
   url: /bob-baumeister

 - name: Henri Beyle
   title: Stendhal
   url: /stendhal

 - name: Jon Doe
   title: jon-doe
   url: https://author.jo