title: Categories date: 2020-01-03 01:23:45 -0800 permalink: /categories/ # trailing slash makes it an `index.html` file inside the `/categories/` directory, rather than a `categories.html` file in the root # dependencies: # site.show.authors sitewide switch to show authors or not # site.projects to show categorized projects # site.pages to show categorized pages


{%-if site.plugins contains 'jekyll-archives'-%}{%-assign archives_available = true-%}{%-else-%}{%-assign archives_available = false-%}{%-endif-%} {%-assign sorted_categories = site.categories | sort %} {%-assign published_projects = site.projects | where: 'published', true-%} {%-assign published_pages = site.pages | where: 'published', true-%} {%-assign project_categories = published_projects | map: 'categories' | join: '—–' | split: '—–' | uniq-%} {%-assign page_categories = published_pages | map: 'categories' | join: '—–' | split: '—–' | uniq-%} {%-assign merged_categories = project_categories | concat: page_categories | uniq | sort-%} <!– Categories –>

  <p>These are the categories used on <a href="{{-site.url-}}">{{-site.title-}}</a> &nbsp;(number of &nbsp;<i class="far fa-sticky-note" style="font-size: 0.9em;"></i>&nbsp;posts{%-if published_projects != empty or published_pages != empty %} / &nbsp;<i class="fas fa-project-diagram" style="font-size: 0.7em;"></i>&nbsp;projects{%-if published_pages != empty %} / &nbsp;<i class="far fa-file-alt" style="font-size: 0.8em;"></i>&nbsp;pages{%-endif-%}{%-endif-%}).</p>
{% for category in sorted_categories-%}
  {%-assign projects  = published_projects  | where_exp: 'project', "project.categories contains category.first"-%}
  {%-assign pages     = published_pages     | where_exp: 'page',    "page.categories    contains category.first"-%}
  <h2 class="tight">
    {% if archives_available-%}
    <a href="/categories/{{-category | first | slugify-}}" title="Articles categorized as '{{-category | first-}}'">{{-category | first | capitalize-}}</a>
    {%-else-%}
    <span title="Articles categorized as '{{-category | first-}}'">{{-category | first | capitalize-}}</span>
    {%-endif %}
    <span class="smaller header-aside"> &nbsp;({{-category | last | size }}{%-if projects != empty or pages != empty %} / {{ projects | size }} / {{ pages | size-}}{%-endif-%})</span>
  </h2>
  <ol>
  {%-for post in category.last %}
    {% include list_item.html-%}
  {%-endfor %}
  {% if projects != empty-%}
    {%-for project in projects %}
    {% include list_item.html li_class="project" title_template="Check out ':item_title'"-%}
    {%-endfor %}
  {%-endif %}
  {%-if pages != empty %}
    {%-for pg in pages %}
    {% include list_item.html li_class="page" title_template="Check out ':item_title'"-%}
    {%-endfor %}
  {%-endif %}
  </ol>
{% endfor-%}

{% if project_categories != empty-%}
  <h2 class="tight" title=""><i class="fas fa-project-diagram" style="font-size: 0.7em;"></i>&nbsp; Project-specific</h2>
{% if site.show.alt_archive_links-%}
  <ul>
  {% for category in project_categories-%}
    {% if site.categories contains category-%}{%-continue-%}{%-endif-%}
    {%-assign projects = published_projects | where_exp: 'project', "project.categories contains category" %}
    <li><a href="/categorys/{{-category | slugify-}}" title="'{{-category | capitalize-}}' projects">{{-category | capitalize-}}</a> &nbsp;({{-projects.size-}})</li>
  {%-endfor %}
  </ul>
{%-else-%}
{% for category in project_categories-%}
  {% if site.categories contains category-%}{%-continue-%}{%-endif-%}
  {%-assign projects = published_projects | where_exp: 'project', "project.categories contains category" %}
  <h3 class="tight" title="'{{-category | capitalize-}}' projects">{{-category | capitalize-}}</h3>
  <ol>
  {%-for project in projects %}
    {% include list_item.html title_template="Check out ':item_title'"-%}
  {%-endfor %}
  </ol>
{%-endfor %}
{% endif-%}
{%-endif %}

{% if page_categories != empty-%}
  <h2 class="tight" title=""><i class="far fa-file-alt" style="font-size: 0.8em;"></i>&nbsp; Page-specific</h2>
{% if site.show.alt_archive_links-%}
  <ul>
  {% for category in page_categories-%}
    {% if site.categories contains category-%}{%-continue-%}{%-endif-%}
    {%-assign site_pages = published_pages | where_exp: 'page', "page.categories contains category"-%}
    <li><a href="/categories/{{-category | slugify-}}" title="'{{-category | capitalize-}}' pages">{{-category | capitalize-}}</a> &nbsp;({{-site_pages.size-}})</li>
  {%-endfor %}
  </ul>
{%-else-%}
{% for category in page_categories-%}
  {% if site.categories contains category-%}{%-continue-%}{%-endif-%}
  {%-assign pages = published_pages | where_exp: 'page', "page.categories contains category" %}
  <h3 class="tight" title="'{{-category | capitalize-}}' pages">{{-category | capitalize-}}</h3>
  <ol>
  {%-for pg in pages %}
    {% include list_item.html title_template="Check out ':item_title'"-%}
  {%-endfor %}
  </ol>
{%-endfor %}
{% endif-%}
{%-endif %}