具有子目录和自己的index.html

问题描述

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

背景信息:我一直在使用Jekyll静态站点生成器,我正在使用的主题具有posts一个博客功能,该功能已经在使用中。 现有循环显示其目录内的所有markdown文件{% assign posts = paginator.posts | where: "lang",page.lang %}{% for post in posts %}

我当前正在使用Jekyll 3.8.5。

目标:创建另一个notes博客。但是,该博客应该能够容纳3个子目录,并可以选择在3个子类别之间进行过滤。顶层目录是“发行说明”,此页面显示所有子目录。 每个子目录应仅显示其特定文件,即iOS仅显示每个markdown文件中按“ 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

解决方法

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

您可以通过在该文件的开头设置以下内容来覆盖它:

permalink: /releasenotes/index.html