Category and Tag page generator for your static Jekyll site.
Ruby
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README.md
category_gen.rb
tag_gen.rb

README.md

Adapted from Charlie Park

Overview

Plugins included in this repository:

  • tag_gen.rb - Generates an index file for each tag listing the applicable posts for each
  • category_gen.rb - Generates an index file for each category listing the applicable posts for each

Usage

For both generators:

Add this plugin as a submodule to your git repo:

            git submodule add git@github.com:jaredwolff/tag_cat_gen.git _plugins/tag_cat_gen

tag_gen.rb

Add tags in a post like this:

            tags:
            - jekyll
            - code

Create a layout generator:

            _layouts/tag_index.html

Put this code in the layout file:

            ---
            layout: blog
            ---
            <div class="content-window">
              <h2 class="post-title">{{page.title}}</h2>
              <ul class="unstyled">
                {% for post in site.posts %}
                {% for tag in post.tags %}
                {% if tag == page.tag %}
                <li><span>{{ post.date | date_to_string }}</span> &raquo; <a href="{{ site.url }}{{ post.url }}">{{ post.title }}</a></li>
                {% endif %}
                {% endfor %}
                {% endfor %}
              </ul>
            </div>

category_gen.rb

Add tags in a post like this:

            category: automobiles

Create a layout generator:

            _layouts/category_index.html

Put this code in the layout file:

            ---
            layout: blog
            ---
            <div class="content-window">
              <h2 class="post-title">{{page.title}}</h2>
              <ul class="unstyled">
                {% for post in site.posts %}
                {% for category in post.categories %}
                {% if category == page.category %}
                <li><span>{{ post.date | date_to_string }}</span> &raquo; <a href="{{ site.url }}{{ post.url }}">{{ post.title }}</a></li>
                {% endif %}
                {% endfor %}
                {% endfor %}
              </ul>
            </div>

###Final note:

Customize as to your needs.