Theldoria's Blog

All about hacking I think is worth to note.

Categories and Tags in Octopress

| Comments

In order to add Categories and Tags pages, create those:

rake new_page[blog/categories]
rake new_page[blog/tags]

And insert the following content:

blog/categories
1
2
3
4
5
<ul>
{% for item in site.categories %}
    <li><a href="/blog/categories/{{ item[0] }}/">{{ item[0] | capitalize }}</a> [ {{ item[1].size }} ]</li>
{% endfor %}
</ul>
plain blog/tags
1
2
3
4
5
<ul>
{% for item in site.tags %}
    <li><a href="/blog/tags/{{ item[0] }}/">{{ item[0] | capitalize }}</a> [ {{ item[1].size }} ]</li>
{% endfor %}
</ul>

Finally add them to the navigation bar:

plain source/_includes/custom/navigation.html
1
2
  <li><a href="{{ root_url }}/blog/categories">Categories</a></li>
  <li><a href="{{ root_url }}/blog/tags">Tags</a></li>

Comments