Jekyll中的Auth.name+URL问题 [英] author.name + URL issue in Jekyll

查看:14
本文介绍了Jekyll中的Auth.name+URL问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我回来做一个Jekyll项目。当我第一次开始这个项目的时候,我在这个页面上询问如何在Jekyll帖子中拉出作者的名字,并被建议使用以下代码:

   {{ site.data.authors[page.author].name }}

...运行得很好。现在我的目标是有一个作者页面,在上面显示作者信息。 我有一个Authors.yml文件(在_data文件中),其中的项结构如下:

john_doe:    
name: John Doe    
email: john@website.com

我使用了Jekyll指南,我的代码在Auths.md页面中如下所示:

<ul>
    {% for author in site.data.authors %}
    <li>
        {{ author.name }}
    </li>
    {% endfor %}
</ul> 

我知道代码的第一部分是有效的,因为我为每个作者显示了一个项目符号,即列表项。然而,列表项返回空,没有作者的名字(最终,我想从YML获取更多信息,但由于我无法完成第一步...)

我尝试切换到此结构,但没有成功:

   - name : john_doe 
   - email: john@email.com

第二个问题:我还设置了指向额外页面的链接,该链接使用了一个Navigation.yml文件,其链接排序如下:

- title: A propos
  url: /about/
  excerpt: ""

这些URL在本地运行良好,但在我将其推送到回收站后就没有这么好的运气了...

如果有人有任何想法..。我被卡住了! 我的回购:https://github.com/piapandelakis/piapandelakis.github.io

推荐答案

创建包含以下内容的数据文件_data/authors.yml

john_doe:    
  name: John Doe    
  email: john@website.com
rms:
  name: Richard Stallman
  email: rms@gnu.org

此结构的好处是,除了能够循环访问所有作者外,还可以在需要的时候单独访问其中的任何作者。

在作者rms的帖子中,您可以显示其信息:

---
author: rms
---

{% assign author = site.data.authors[page.author] %}
<div> Author: {{ author.name }}
</div>

显示所有作者的列表:

{% for author in site.data.authors %}
{{author[1].name}} <br>
{% endfor %}

这篇关于Jekyll中的Auth.name+URL问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆