Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamshacky/6d6ec71a70203f2bdebf97d98786bd0d to your computer and use it in GitHub Desktop.
Save iamshacky/6d6ec71a70203f2bdebf97d98786bd0d to your computer and use it in GitHub Desktop.
Loop through Jekyll collections and output their content as sections and articles
{% comment %}
Loops though every collection you defined in _config.yml and grabs the pages they contain; outputting title and full text with good basic html semantics.
Use page.excerpt instead of page.content to grab the first paragraph, blog list style. Markdownify is optional, depends how you authored content in your collections; I typically use Markdown.
{% endcomment % }
{% for collection in site.collections %}
{% assign name = collection.label %}
<section>
<h1>{{ name }}</h1>
{% for page in site.[name] %}
<article>
<h2>{{ page.title }}</h2>
<p>{{ page.content | markdownify }}</p>
</article>
{% endfor %}
</section>
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment