我正在使用Jekyll创建一个博客网站,我想在主页上添加一个简短的"关于"部分。我将创建一个"关于我"帖子(about-me.md(,而不是创建一个单独的段落,并在主页上插入该帖子的摘录(在其下方将是一个链接来阅读文章的其余部分(。
我能在网上找到的唯一信息是关于"最新帖子"部分,利用"for"循环显示 5 个(或更多(最近的帖子。我在 Jekyll 文档中找不到任何其他解释如何显示特定帖子摘录的内容。
我试过改变
{{ post.excerpt }}
自
{{ about-me.excerpt }}
但无济于事。
以下是"最近发布"的实现:
<div class="about-section">
<h1>About Me</h1>
<ul>
{% for post in site.posts %}
<li>
<a href="{{ post.url }}">{{ post.title }}</a>
{{ post.excerpt }}
</li>
{% endfor %}
</ul>
</div>
这适用于显示最近的帖子,包括摘录。我只需要在标题下方显示"about-me.md"帖子的摘录。
确保你的关于我的帖子的 YML/前言看起来像这样:
---
title: About me
featured: true
---
The content of your post...
并确保主页布局如下所示:
<div class="about-section">
<h1>About Me</h1>
<ul>
{% assign featuredposts = site.posts | where:'featured','true' %}
{% for post in featuredposts limit:1 %}
<li>
<a href="{{ post.url }}">{{ post.title }}</a>
{{ post.excerpt }}
</li>
{% endfor %}
</ul>
</div>