我如何为标签使用 Collection

How can i use a Collection for Tags

我有一个 collection _authors 和一些条目。

我想通过以下方式将 author-tag 分配给我的 post:

{% assign author = site.authors | where: "title", page.author | first %}
 {% if author %}
  <a href="{{ author.url }}">{{ author.title }}</a>
{% endif %}

我只用像 Bob 这样的名字测试了它,它有效。如果我在我的 authors-collection 中选择像 Bob Baumeister 这样的姓名作为标题,它就不起作用。有谁知道为什么会这样?

前言示例 post:

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

Content

前言示例 Collection 条目:

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

Content

感谢您的帮助。

试试 " :

author: "Bob Baumeister"

更新

<!-- Bob Bau => bob-bau -->
{% assign slug = page.author | slugify  %}

<!-- filter by the slugified title -->
{% assign author = site.authors | where: "title", slug | first%}
...

但我认为使用 authors.yml 文件而不是集合可以提供更大的灵活性:

 - 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