我想使用Jekyll的标准主题“Minima”创建一个自定义的“主页”页面。默认情况下,它设置为最近的博客文章列表:

---
layout: default
---

<div class="home">

  <h1 class="page-heading">Posts</h1>

  {{ content }}

  <ul class="post-list">
    {% for post in site.posts %}
      <li>
        <span class="post-meta">{{ post.date | date: "%b %-d, %Y" }}</span>

        <h2>
          <a class="post-link" href="{{ post.url | relative_url }}">{{ post.title | escape }}</a>
        </h2>
      </li>
    {% endfor %}
  </ul>

  <p class="rss-subscribe">subscribe <a href="{{ "/feed.xml" | relative_url }}">via RSS</a></p>

</div>

此设置在文件_layouts/home.html中进行控制。我已经使用Markdown创建了自定义的“主页”页面。它保存在我的本地目录中,名为“aboutme.md”:
---
layout: page
title: About Me
permalink: /aboutme/
order: 1
---

This is a custom about me page.

我想覆盖最近的帖子的默认列表,并用我的自定义“aboutme”页面替换它。如何以一种优雅的方式实现这一目标?一种方法是用HTML重写“aboutme.md”,然后将其保存到“home.hml”中。但是,它使工作加倍。我确定必须有一种方法可以通过简单的Liquid命令在“home.html”中“包含”“aboutme.md”页面。我还希望站点菜单中显示“关于我”页面。

最佳答案

您应该将“aboutme.md”文件重命名为“index.md”,删除永久链接语句,然后将其保存在网站目录的根目录中(还可以将旧的index.md重命名为blog.md)。

像这样:(index.md)

---
layout: page
title: About Me
order: 1
---

This is now the homepage.

09-11 17:36
查看更多