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

标签 collections tags jekyll subdirectory static-site

您好,提前感谢您对我的问题的任何帮助/建议,
背景资料:我一直在使用 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 %}
然后将此代码注入(inject) 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

关于collections - 带有子目录和自己的 index.html 的 Jekyll 集合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64557906/

相关文章:

android - 区分NTAG213和MF0ICU2

javascript - 按键值对数组排序

ruby - ffi Ruby Gem 编译失败

java - 在 Java 中实现最佳匹配搜索

java - 在对象上设置属性会重置 ArrayList 中类似对象的相同属性

amazon-web-services - 地形。标记使用 Autoscaling 组创建的实例

gitlab - Jekyll 构建在 GitLab 上中断,打包器问题

jekyll - 更改包含的文件时如何使 jekyll serve --watch 重建?

Java 集合 API 错误?

java - 什么是具有独特元素(如集合)和获取元素功能的正确Java集合