Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jekyll collection with subdirectories and own index.html

Hello and thank you in advance for any help/suggestions regarding my issue,

Background information: I have been working with the Jekyll static-site generator, The theme I am using has one blog feature being posts this is in use already. The existing loop shows all the markdown files within its directory: {% assign posts = paginator.posts | where: "lang", page.lang %}{% for post in posts %}

I am currently using Jekyll 3.8.5.

Goal: Create a second blog being notes. However, this blog should be able to house 3 subdirectories with the option to filter between the 3 subcategories. The top-level directory is ‘release notes’ this page should show all subdirectories. Each subdirectory should only show their specific files i.e. iOS only shows the specific release notes filtered by category ‘iOS’ in each markdown file.

I want to create a second blog called ‘release notes’ housing 3 different sub-collections (categories), being Android, iOS, and Windows; each subdirectory of release notes will host several Markdown files which will all be of the same type (same tag or category)

Structure:

_releasenotes
  - ios
  - android
  - windows

I have tried to implement the function using the approach from this thread: [https://stackoverflow.com/a/38870168/1914835][1] without complete success.

Approach: Creating an individual index.html for _releasenotes this will show all markdown files within that directory using this loop:

{% 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 %}

This code is then injected into the index.html within the release notes directory which simply looks like this:

---
title: release notes
---
{% include list-releasenotes.html %}

Outcome: Once the site builds it replaces the created index.html with the original site index.html which defeats the purpose. Each sub-collection has its own ‘index.html’ which for-loops all the MD files within. Jekyll however does not use the provided index pages for each collection but rather generates its own index.html being the (wrong) ‘landing page’.

Jekyll generates releasenotes/index/index.html :(

Giving me:

public
- releasenotes
    - index.html (the original site index.html)
    /ios
    /android
    /windows
    /index/index.html (mine that includes another html)

Instead of:

public
- releasenotes
    - index.html (Mine which includes another html)
    /ios
    /android
    /windows

How can I configure Jekyll that it doesn’t convert my index.html (in _releasenotes) to a subdirectory but should use my created index.html as the entry page for release notes? Keeping in mind that I can see all release notes within the release notes folder and within the subfolder, I should be able to filter between iOS, Android and Windows.

Here are the collection configurations:

collections:
  releasenotes:
    output: true
    android:
      output: true
    ios:
      output: true
    portal:
      output: true
like image 246
FelixAusbildo Avatar asked Oct 27 '20 15:10

FelixAusbildo


1 Answers

The _releasenotes/index.html collection item file is output to releasenotes/index/index.html because of the default permalink setting.

You can overwrite it by setting this in the front matter for that file:

permalink: /releasenotes/index.html
like image 119
Ross Avatar answered Oct 06 '22 13:10

Ross