Creating categories on Jekyll driven site
You can generate a list of all the available categories by using the site.categories
data, using the first element of each category (which is an array) to get the category name:
{% for cat in site.categories %}
<li>{{ cat[0] }}</li>
{% endfor %}
And you can generate a list of all the posts in a given category like so:
{% for post in site.categories.CATEGORY_NAME %}
It doesn't seem possible to generate an individual HTML page for each category as you were hoping, but perhaps a good compromise would be to generate a single page containing a list of all categories, where each category contains all the posts in that category. You could then use some simple JavaScript to hide the posts in each category until the category name is selected, giving almost the same user experience as individual archive pages for each category.
In Jekyll: Want to use category (or tag) name in a list, but not all posts in a category
You are looking at the correct site.categories
, but for the name, you must reference the first object in the array as category[0]
.
Regarding tag lists, you may want to look at this helper class.
UPDATE:
A more elegant way to code this, using the Liquid templating engine's filter, would be:
{% for category in site.categories %}
{{ category | first }}
{% endfor %}
Jekyll display posts by category
Got it! Needed an intermediate posts loop before listing out individual posts
<ul>
{% for category in site.categories %}
<li><a name="{{ category | first }}">{{ category | first }}</a>
<ul>
{% for post in category.last %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
An easy way to support tags in a jekyll blog
This gist will generate a page per category for you: https://gist.github.com/524748
It uses a Jekyll Generator plugin, plus a Page subclass.
using jekyll pagination to display a custom categories
i also tried to build my page with jekyll-paginate
but as the plugin is no longer under active development, i switched to octopress-paginate.
This allows us you use a simple syntax like:
{% for post in paginator.posts %}
or any other collection / page-type you have.
Jekyll multiple custom repeatable content
I figured out the problem. First one is the folder structure. Simply keep all the postfiles in the _posts/ file in the root directory. The second one is the capitalization of the category name in your liquid tag. Although there are no semantic differences between JOBS and jobs, when used in liquid arguments, they act in a weird way. So try to keep them in lower case. Simply replace the line
{% for post in site.categories.JOBS %}
with this
{% for post in site.categories.jobs %}
This won't solve your problem right away. Jekyll expects you to wrap your posts YAML matter between --- 3 dashes. So you've to use the following format for you post markdown and everything will work:
---
title: test
category: jobs
length: April 2010 – April 2012
position: Junior Developer
---
Content to be displayed
Related Topics
Better Way to Turn a Ruby Class into a Module Than Using Refinements
Unit Test in Rails - Model with Paperclip
How to Get Request's Target Controller and Action with Rails 3
Creating Categories on Jekyll Driven Site
How Does Rails Implement Before_Filter
Should I Use Class Method or Instance Method, and Why
Are There Unintended Consequences of Ruby's 'Begin ... End' Without 'Rescue' Used as a Code Block
How to Validate Associated Model Id
Sorting a Two-Dimensional Array by Second Value
Rails: How to Determine Controller/Action in View
How to Add Two Weeks to Time.Now
How Are Symbols Used to Identify Arguments in Ruby Methods
Rails Belongs_To Association (With :Class_Name) Returns Nil
How to Monitor Uptime of 20 Websites (Ping or Http) in Node.Js/Ror
How to Replace Multiple Newlines in a Row with One Newline Using Ruby