Awesome nav demo

Layout Integration

jekyll-awesome-nav generates navigation data. Your layout renders it.

This site uses its own small demo layout at site/_layouts/awesome_nav_demo.html, with a recursive include at site/_includes/awesome-nav-tree.html.

You can use those files as a starting point when wiring the same data into another Jekyll theme.

Enable a docs layout

Set a layout for every page under your docs root:

defaults:
  - scope:
      path: "docs"
    values:
      layout: awesome_nav_demo

Inside that layout, check for generated navigation before rendering plugin-specific UI:

{% if page.awesome_nav %}
  <!-- Render awesome nav UI -->
{% endif %}

Render breadcrumbs

The plugin writes breadcrumbs to page.breadcrumbs.

{% if page.breadcrumbs %}
<nav aria-label="Breadcrumbs">
  <ol>
    {% for item in page.breadcrumbs %}
      <li>
        {% if item.url %}
          <a href="{{ item.url | relative_url }}">{{ item.title }}</a>
        {% else %}
          <span>{{ item.title }}</span>
        {% endif %}
      </li>
    {% endfor %}
  </ol>
</nav>
{% endif %}

Render a sidebar

Use page.awesome_nav for the full docs tree. Each item includes current for the exact page match and contains_current for the active branch:

<nav aria-label="Documentation">
  <ul>
    {% for item in page.awesome_nav %}
      <li>
        <a href="{{ item.url | relative_url }}"{% if item.current %} aria-current="page"{% endif %}>{{ item.title }}</a>
        {% if item.contains_current %}
          <span class="visually-hidden">(current section)</span>
        {% endif %}
        {% if item.children %}
          <ul>
            {% for child in item.children %}
              <li><a href="{{ child.url | relative_url }}">{{ child.title }}</a></li>
            {% endfor %}
          </ul>
        {% endif %}
      </li>
    {% endfor %}
  </ul>
</nav>

For deeply nested docs, move the recursive portion into an include and call it for each children collection.

Render the current section

Use page.awesome_nav_local when you want a compact menu for the current directory:

{% if page.awesome_nav_local %}
<nav aria-label="This section">
  <ul>
    {% for item in page.awesome_nav_local %}
      <li><a href="{{ item.url | relative_url }}">{{ item.title }}</a></li>
    {% endfor %}
  </ul>
</nav>
{% endif %}

The plugin calculates previous and next pages from the final resolved tree, including local .nav.yml overrides.

<nav aria-label="Pagination">
  {% if page.awesome_nav_previous %}
    <a href="{{ page.awesome_nav_previous.url | relative_url }}">
      Previous: {{ page.awesome_nav_previous.title }}
    </a>
  {% endif %}

  {% if page.awesome_nav_next %}
    <a href="{{ page.awesome_nav_next.url | relative_url }}">
      Next: {{ page.awesome_nav_next.title }}
    </a>
  {% endif %}
</nav>

Theme includes

If you maintain a theme, a clean pattern is:

  • one include for breadcrumbs
  • one recursive include for tree rendering
  • one layout that chooses full-tree or local-section navigation

That keeps the plugin data plain and lets the theme own the HTML and CSS.

Plugin data Resolved page variables for this page

page.breadcrumbs

[{"title":"Documentation","url":"/docs/"},{"title":"Guides","url":"/docs/guides/"},{"title":"Layout Integration","url":"/docs/guides/layouts/"}]

page.awesome_nav

[{"title":"Getting Started","url":"/docs/getting-started/","current":false,"contains_current":false},{"title":"Guides","url":"/docs/guides/","children":[{"title":"Install Guide","url":"/docs/guides/install/","current":false,"contains_current":false},{"title":"Layout Integration","url":"/docs/guides/layouts/","current":true,"contains_current":true},{"title":"Configuration","url":"/docs/guides/config/","current":false,"contains_current":false},{"title":".nav.yml Reference","url":"/docs/guides/nav-file/","current":false,"contains_current":false},{"title":"Navigation Overrides","url":"/docs/guides/overrides/","current":false,"contains_current":false},{"title":"Generated Data","url":"/docs/guides/data/","current":false,"contains_current":false}],"current":false,"contains_current":true},{"title":"Examples","children":[{"title":"Examples Home","url":"/docs/examples/","current":false,"contains_current":false},{"title":"Basic Folder Navigation","url":"/docs/examples/basic-folder-navigation/","current":false,"contains_current":false},{"title":"Local Override","url":"/docs/examples/local-override/","current":false,"contains_current":false}],"current":false,"contains_current":false}]

page.awesome_nav_local

[{"title":"Install Guide","url":"/docs/guides/install/"},{"title":"Layout Integration","url":"/docs/guides/layouts/"},{"title":"Configuration","url":"/docs/guides/config/"},{"title":".nav.yml Reference","url":"/docs/guides/nav-file/"},{"title":"Navigation Overrides","url":"/docs/guides/overrides/"},{"title":"Generated Data","url":"/docs/guides/data/"}]

page.awesome_nav_dir

"docs/guides"

page.awesome_nav_previous

{"title":"Install Guide","url":"/docs/guides/install/"}

page.awesome_nav_next

{"title":"Configuration","url":"/docs/guides/config/"}