Tags provide another means of navigation for your content. Unlike the table of contents, tags can show the content in a variety of arrangements and groupings. Implementing tags in this Jekyll theme is somewhat of a manual process.
Edit me

Add a tag to a page

You can add tags to pages by adding tags in the frontmatter with values inside brackets, like this:

---
title: 2.0 Release Notes
permalink: /release_notes_2_0/
tags: [formatting, single-sourcing]
---

Tags overview

To prevent tags from getting out of control and inconsistent, first make sure the tag appears in the \date/tags_doc.yml file. If it's not there, the tag you add to a page won't be read. I added this check just to make sure I'm using the same tags consistently and not adding new tags that don't have tag archive pages.

Additionally, you must create a tag archive page similar to the other pages named tag-{tagname}.html folder. This theme doesn't auto-create tag archive pages.

For simplicity, make all your tags single words (connect them with hyphens if necessary).

Setting up tags

Tags have a few components.

  1. First make sure you configure a few details in the conditions.html file. In particular, see this setting:

    {% assign projectTags = site.data.tags_doc.allowed-tags %}
    

    The tags_doc name must correspond with how you label your tags file. Here, "doc" should be your project name.

  2. In the _data file, add a yml file similar to tags_doc.yml. The YML file lists the tags that are allowed:

    allowed-tags:
      - getting-started
      - overview
      - formatting
      - publishing
      - single-sourcing
      - special-layouts
      - content types
    
  3. Create a tag archive file for each tag in your tags_doc.yml list. Name the file like this: tag-getting-started.html, where doc is your project name. (Again, tags with multiple words need hyphens in them.)

    Each tag archive file needs only this:

    ---
    title: "Getting Started Pages"
    tagName: getting-started
    ---
    {% include taglogic.html %}
    
    <div class="alert alert-info" role="alert"><i class="fa fa-info-circle"></i> <b>Note: </b>In the \_includes folder, there's a taglogic.html file. This file (included in each tag archive file) has common logic for getting the tags and listing out the pages containing the tag in a table with summaries or truncated excerpts. You don't have to do anything with the file &mdash; just leave it there because the tag archive pages reference it.</div>
    
  4. Adjust button color or tag placement as desired.

    By default, the _layouts/page.html file will look for any tags on a page and insert them at the bottom of the page using this code:

    <div class="tags">
        {% if page.tags != null %}
        <b>Tags: </b>
        {% include custom/conditions.html %}
        {% for tag in page.tags %}
        {% if projectTags contains tag %}
           <a href="tag-{{tag}}.html" class="btn btn-info navbar-btn cursorNorm" role="button">{{page.tagName}}{{tag}}</a>
        {% endif %}
        {% endfor %}
        {% endif %}
    </div>
    

    Here's an example of what the code does:

    Tags:

    <a href="tag-navigation.html" class="btn btn-info navbar-btn cursorNorm" role="button">navigation</a>