0
votes

Hi I'm new to Jekyll and have a basic blog set up. Now my idea is to loop through a collection per blog post to get some fancy HTML going on. Because as far as I'm aware you can't simply add HTML to the markdown.

// config.yml

collections:
  - hollowknight

So I've set up a collection named hollowknight and I got a blog post about Hollow Knight. In the Front Matter of the blog post I have collectionid: 'hollowknight'. And in the Layout I use for blog posts I tried the following:

// post.html

{% capture collection %}site.{{ page.collectionid }}{% endcapture %}

{% for section in collection %}
  {{ section.title }}
{% endfor %}

So the idea was to set the collection variable to site.hollowknight as configured in the config and the Front Matter. I set up a single article inside the collection, but it isn't showing up.

Is there any way to realise this? Edit: https://talk.jekyllrb.com/t/list-collection-with-name-from-front-matter/3619/6

Or is there a way to use paragraphs in the Front Matter, because then I could just use arrays and objects in the Front Matter of the posts to do my magic?
Edit: https://github.com/jekyll/jekyll/issues/246#issuecomment-1639375

Or am I just stretching to far from what Jekyll is supposed to be?


Edit

So I found out I was getting the collection the wrong way, https://talk.jekyllrb.com/t/list-collection-with-name-from-front-matter/3619/6.

{% for section in site.[page.collectionid] %}
  {{ section.content | textilize }}
{% endfor %}

The only weird part is, everywhere I see | textilize being used but can't get it to work.

1

1 Answers

0
votes

This is the final solutions:

{% for section in site.[page.collectionid] %}
  {{ section.content | markdownify }}
{% endfor %}

It's markdownify instead of textilize.

Also I ended up using a Front Matter array with objects to loop through instead of a collection to keep it more organized.