Skip to content

Instantly share code, notes, and snippets.

@brehehe
Forked from roachhd/README.md
Created July 2, 2018 04:34
Show Gist options
  • Save brehehe/c28a15373e44495e1473140ab0dcc194 to your computer and use it in GitHub Desktop.
Save brehehe/c28a15373e44495e1473140ab0dcc194 to your computer and use it in GitHub Desktop.
Jekyll - Get a list of PAGES in a given Category -not posts- for

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