我想使用 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.
我想覆盖最近帖子的默认列表,并将其替换为我的自定义“关于我”页面。我怎样才能以优雅的方式实现这一目标?一种方法是用 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.
关于html - 使用 Jekyll 创建自定义主页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46605882/