DiGirolamo Knows

Let the tinkering begin

Octopress Category Listing

While setting up my side bar for this site I wanted to easily list all categories from all posts. Unfortunately, this is non-trivial from what I learned by skimming the Octopress, Jekyll, and Liquid docs. Fortunately, there is an easy fix. Here are the diffs of the changes I made:

(category_generator.diff) download
1
2
3
4
5
6
7
8
9
10
11
12
diff --git a/plugins/category_generator.rb b/plugins/category_generator.rb
index d9357bc..49e9d40 100644
--- a/plugins/category_generator.rb
+++ b/plugins/category_generator.rb
@@ -106,6 +106,7 @@ module Jekyll
     #
     def category_links(categories)
       dir = @context.registers[:site].config['category_dir']
+      categories = categories.keys if categories.class == Hash
       categories = categories.sort!.map do |item|
         "<a class='category' href='/#{dir}/#{item.gsub(/_|\P{Word}/, '-').gsub(/-{2,}/, '-').downcase}/'>#{item}</
       end
(recent_posts.diff) download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/source/_includes/asides/recent_posts.html b/source/_includes/asides/recent_posts.html
index cc62814..b12f77c 100644
--- a/source/_includes/asides/recent_posts.html
+++ b/source/_includes/asides/recent_posts.html
@@ -1,4 +1,11 @@
 <section>
+  <h1>Categories</h1>
+  <ul>
+    <li>
+      {{ site.categories | category_links }}
+    </li>
+  </ul>
+
   <h1>Recent Posts</h1>
   <ul id="recent_posts">
     {% for post in site.posts limit: site.recent_posts %}

This allows the category_links liquid filter to process the site.categories hash. The line added to category_generator.rb file gets the keys of site.categories which corresponds to the names of every category.

./configure –prefix=$HOME

Hello world, I am a software engineer working in High Performance Computing. Currently I am with the OLCF working as their Software Czar. That’s the fancy name for the person who decides what software will be installed center-wide and gets things done. The OLCF is the name given to the department responsible for marinating all supercomputers a Oak Ridge National Laboratory (ORNL). It’s the most recent name chosen, previously known as NCCS.

My background is Computer Science, for details please see my resume. Recently, I’ve taken a liking to hardware design and construction. Most of my posts here will cover that topic.

Thanks for stopping by!