I'm creating a blog site using Jekyll and I want to add a short "about" section on the homepage. Instead of creating a separate paragraph, I'm going to create an "About Me" post (about-me.md) and insert an excerpt from that post on the homepage in its place (beneath it will be a link to read the rest of the article).
The only information I can find online is about the "latest posts" section utilizing the 'for' loop to show the 5 (or more) recent posts. I can't find anything else in the Jekyll documentation that explains how to display an excerpt from one specific post.
I've tried changing
{{ post.excerpt }}
to
{{ about-me.excerpt }}
but to no avail.
Below is the 'recent posts' implementation:
<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>
This works to display the recent posts including an excerpt. I need to only display the excerpt from the 'about-me.md' post immediately under the title.
Make sure the YML/front matter of your about-me post looks like this:
---
title: About me
featured: true
---
The content of your post...
And make sure the home page layout looks like this:
<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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.