Skip to content

Instantly share code, notes, and snippets.

@roachhd
Last active November 1, 2023 00:50
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roachhd/0991292c575536db96c5 to your computer and use it in GitHub Desktop.
Save roachhd/0991292c575536db96c5 to your computer and use it in GitHub Desktop.
JEKYLL TIPS πŸ’Ž. list of posts with excerpt - description or content.

#JEKYLL TIPS πŸ’Ž.

List of posts with excerpt, description or full post content.

List of posts with except

<ul>
  {% for post in site.posts %}
    <li>
      <a href="{{ post.permalink }}">{{ post.title }}</a>
      <p>{{ post.excerpt }}</p>
    </li>
  {% endfor %}
</ul>

List of posts with full content

<ul>
  {% for post in site.posts %}
    <li>
      <a href="{{ post.permalink }}">{{ post.title }}</a>
      <p>{{ content }}</p>
    </li>
  {% endfor %}
</ul>

List if posts with post description

<ul>
  {% for post in site.posts %}
    <li>
      <a href="{{ post.permalink }}">{{ post.title }}</a>
      <p>{{ post.description }}</p>
    </li>
  {% endfor %}
</ul>

Pages

List of Pages with description. (change to excerpt or content)

<ul>
  {% for post in site.page %}
    <li>
      <a href="{{ page.permalink }}">{{ page.title }}</a>
      <p>{{ page.description }}</p>
    </li>
  {% endfor %}
</ul>

post can be replaced with page or even site depending on your need.

See Jekyll Docs for more details.


List of posts/pages in a category ❀

on _config.yml add your index of categories:

categories: [bacon, dogs, cows, mull, stink]

on your page.md inside the front matter add one or more of the categories available in the _config.yml

---
layout: page
title: Stinky Trees
description: Mull Congress from stinky trees.
categories: [stink, mull]
---

on your template to get all the pages in the stink category you do:

{% for page in site.pages %}
  {% if page.categories contains 'stink' %}
    <div class="item">
      <h3><a href="{{ page.url }}">
        {{ page.title }}
      </a></h3>

      <p>{{page.description}}</p>  
    </div>
  {% endif %}
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment