带有子目录和自己的 index.html 的 Jekyll 集合

Fel*_*ldo 5 tags collections static-site subdirectory jekyll

您好,提前感谢您对我的问题的任何帮助/建议,

背景信息:我一直在使用 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
Run Code Online (Sandbox Code Playgroud)

我尝试使用此线程中的方法实现该功能:[/sf/answers/2720911791/][1] 没有完全成功。

方法_releasenotes为此创建一个单独的 index.html将使用此循环显示该目录中的所有降价文件:

{% 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 %}
Run Code Online (Sandbox Code Playgroud)

然后将此代码注入index.html发行说明目录中,该目录如下所示:

---
title: release notes
---
{% include list-releasenotes.html %}
Run Code Online (Sandbox Code Playgroud)

结果:一旦站点建立,它就会用原始站点 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)
Run Code Online (Sandbox Code Playgroud)

代替:

public
- releasenotes
    - index.html (Mine which includes another html)
    /ios
    /android
    /windows
Run Code Online (Sandbox Code Playgroud)

如何配置 Jekyll 使其不会将我的 index.html(在 _releasenotes 中)转换为子目录,而是应该使用我创建的 index.html 作为发行说明的入口页面?请记住,我可以在发行说明文件夹和子文件夹中看到所有发行说明,我应该能够在 iOS、Android 和 Windows 之间进行过滤。

以下是集合配置:

collections:
  releasenotes:
    output: true
    android:
      output: true
    ios:
      output: true
    portal:
      output: true
Run Code Online (Sandbox Code Playgroud)

Ros*_*oss 5

收集_releasenotes/index.html项目文件输出到releasenotes/index/index.html由于默认的永久链接设置,

您可以通过在该文件的前面设置此项来覆盖它:

permalink: /releasenotes/index.html
Run Code Online (Sandbox Code Playgroud)