jekyll-bootstrap icon indicating copy to clipboard operation
jekyll-bootstrap copied to clipboard

Alphabetize Categories and Tags

Open shellscape opened this issue 10 years ago • 0 comments

It'd be a great advantage to be able to alphabetize both the categories and tags list on each respective page. When dealing with a large number of categories/tags it makes it very hard for users to pinpoint a tag or subject without any kind of organization.

Skimmed this from a few examples on Stack Exchange, and it works very well:

{% capture tags %}{% for tag in site.tags %}{{ tag[0] }}|{% endfor %}{% endcapture %}
{% assign sortedtags = tags | split:'|' | sort %}
{% for tag in sortedtags %}
  <h2 id="{{ tag }}-ref">{{ tag }}</h2>
  <ul>
    {% assign pages_list = site.tags[tag] %}
    {% include JB/pages_list %}
  </ul>
{% endfor %}

shellscape avatar Jun 23 '15 03:06 shellscape