【发布时间】:2021-02-09 22:28:48
【问题描述】:
您好,提前感谢您对我的问题提供任何帮助/建议,
背景信息:我一直在使用 Jekyll 静态站点生成器,我正在使用的主题有一个博客功能是 posts,这已经在使用中。
现有循环显示其目录中的所有降价文件:
{% assign posts = paginator.posts | where: "lang", page.lang %}{% for post in posts %}
我目前正在使用 Jekyll 3.8.5。
目标:创建第二个博客notes。但是,该博客应该能够容纳 3 个子目录,并可以在 3 个子类别之间进行过滤。顶级目录是“发行说明”,此页面应显示所有子目录。
每个子目录应仅显示其特定文件,即 iOS 仅显示每个降价文件中按“iOS”类别过滤的特定发行说明。
我想创建第二个名为“发行说明”的博客,其中包含 3 个不同的子集合(类别),即 Android、iOS 和 Windows;发行说明的每个子目录都将包含多个 Markdown 文件,这些文件都属于同一类型(相同的标签或类别)
结构:
_releasenotes
- ios
- android
- windows
我尝试使用该线程中的方法实现该功能:[https://stackoverflow.com/a/38870168/1914835][1] 但没有完全成功。
方法:为_releasenotes 创建一个单独的 index.html,这将使用此循环显示该目录中的所有 markdown 文件:
{% assign notes = site.releasenotes| sort:'title' %}
{% for note in notes %}
{% if page.url != note.url and include.category == nil or note.url contains include.category %}
<a href={{ note.url | prepend: site.baseurl }}>{{note.title}}</a>
{% endif %}
{% endfor %}
然后将此代码注入到发布说明目录中的index.html,如下所示:
---
title: release notes
---
{% include list-releasenotes.html %}
结果:站点构建后,它会将创建的 index.html 替换为原始站点 index.html,这违背了目的。 每个子集合都有自己的“index.html”,用于循环其中的所有 MD 文件。然而,Jekyll 并没有为每个集合使用提供的索引页面,而是生成自己的 index.html 作为(错误的)“登陆页面”。
Jekyll 生成 releasenotes/index/index.html :(
给我:
public
- releasenotes
- index.html (the original site index.html)
/ios
/android
/windows
/index/index.html (mine that includes another html)
代替:
public
- releasenotes
- index.html (Mine which includes another html)
/ios
/android
/windows
如何配置 Jekyll,使其不会将我的 index.html(在 _releasenotes 中)转换为子目录,但应该使用我创建的 index.html 作为发行说明的入口页面? 请记住,我可以在发行说明文件夹和子文件夹中看到所有发行说明,我应该能够在 iOS、Android 和 Windows 之间进行筛选。
以下是集合配置:
collections:
releasenotes:
output: true
android:
output: true
ios:
output: true
portal:
output: true
【问题讨论】:
标签: collections tags jekyll subdirectory static-site