4

i'm kinda new to jekyll. in my project i have few .md files(each file relate to a portfolio project). some of those need to generate separate .html files when built(which jekyll already does). but i want to exclude some files from being creating separate html files.

But the important thing is, even though i want to exclude those .md files from creating seperate .html files i still want to use the front matter of those files.(as i'm using a for loop to generate a list of all the portfolio projects)

i tryied adding those .md files to the _config.yml under exclude. but that will stop parsing the front matter as well.

is there a way in jekyll which i can achieve this.

edit:

project1.md

---
title: project1
display: true
category: portfolioProjects
---

This is a test content

project2.md

---
title: project2
display: false
category: portfolioProjects
---

if i have 2 files like above, i would like to render project1.md as a .html file(as it has a content to be shown in a page) and not generate project2.md as a separate file.But i still want to access front matters of both files to make a list of projects like,

{% for project in site.projects %}
{{project.title}}
{% endfor %} 

I believe i can use 2 types of collections and set output to true for one type of collection and false to other type of collection. But I'm wondering whether there is a much cleaner way like conditionally setting output to true or false depending on a front matter value. eg. output : (display)? true : false

mahathun
  • 59
  • 1
  • 8
  • https://jekyllrb.com/docs/collections/ – David Jacquel Feb 02 '17 at 18:39
  • @DavidJacquel thanks for the link, but i still coudn't figure out a way to access front meta from _config.yml. i can use a new collection and use the output property to make those type of collection files to generate a .html file or not. But i want to conditionally set output to `true || false` depending on a front matter attribute inside the collection files. is this possible in jekyll – mahathun Feb 02 '17 at 22:22
  • No way with raw jekyll. You will need to write a plugin. – David Jacquel Feb 03 '17 at 10:47
  • Can't you just add an additional no_display category to the respective files and exclude all posts matching this category when looping through all your posts? – Windowlicker Feb 03 '17 at 11:49
  • what did you end up doing. I tried 2 collections, one with output true, other false. they are both generating for me. – kbrock May 13 '20 at 06:39

0 Answers0