您好,提前感谢您对我的问题的任何帮助/建议,
背景资料:我一直在使用 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/