All Projects → forestryio → Jekyll Menus

forestryio / Jekyll Menus

Licence: mit
A menus (site navigation) plugin for your Jekyll website that also works with https://forestry.io (Jekyll CMS)

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Jekyll Menus

Jekyll Toc
A GitHub Pages compatible Table of Contents generator without a plugin or JavaScript
Stars: ✭ 306 (+166.09%)
Mutual labels:  jekyll, liquid
Jekyll Rss Feeds
Templates for rendering RSS feeds for your Jekyll blog
Stars: ✭ 627 (+445.22%)
Mutual labels:  jekyll, liquid
Jekyll Timeago
⌛️ Ruby library to compute distance of dates in words. Originally built for Jekyll.
Stars: ✭ 130 (+13.04%)
Mutual labels:  jekyll, liquid
Jekyll
🌐 Jekyll is a blog-aware static site generator in Ruby
Stars: ✭ 43,803 (+37989.57%)
Mutual labels:  jekyll, liquid
Gojekyll
A fast clone of the Jekyll blogging engine, in Go
Stars: ✭ 62 (-46.09%)
Mutual labels:  jekyll, liquid
Jekyll Liquify
A Jekyll filter that parses Liquid from front matter
Stars: ✭ 21 (-81.74%)
Mutual labels:  jekyll, liquid
Alembic
⚗️ A Jekyll boilerplate theme designed to be a starting point for any Jekyll website
Stars: ✭ 501 (+335.65%)
Mutual labels:  jekyll, liquid
Glim
Static site generator which is semi-compatible with Jekyll
Stars: ✭ 76 (-33.91%)
Mutual labels:  jekyll, liquid
Jekyll Assets
🎨 Asset pipelines for Jekyll.
Stars: ✭ 1,083 (+841.74%)
Mutual labels:  jekyll, liquid
Jekyll Timeline
Timeline / Résumé Theme with Jekyll
Stars: ✭ 46 (-60%)
Mutual labels:  jekyll, liquid
Rustycrate.ru
Русскоязычный сайт о языке программирования Rust
Stars: ✭ 72 (-37.39%)
Mutual labels:  jekyll, liquid
Garth
🥁 A really basic theme for Jekyll
Stars: ✭ 85 (-26.09%)
Mutual labels:  jekyll, liquid
Shopify Theme Inspector
A Chrome DevTools plugin that visualizes Shopify Liquid render profiling data so you can triage long-running code and reduce server response times!
Stars: ✭ 102 (-11.3%)
Mutual labels:  liquid
Athena
A simple and elegant theme for Jekyll and GitHub Pages.
Stars: ✭ 109 (-5.22%)
Mutual labels:  jekyll
Nandomoreira Jekyll Theme
💎 My old website in Jekyll and Gulpjs
Stars: ✭ 101 (-12.17%)
Mutual labels:  jekyll
Jekylltheme Projectgaia
Jekyll Theme Project Gaia. V2 Beta Released !! Check it out ->
Stars: ✭ 111 (-3.48%)
Mutual labels:  jekyll
Shopify Shortcodes
Allows you to use Shortcodes within Shopify
Stars: ✭ 100 (-13.04%)
Mutual labels:  liquid
Scriban
A fast, powerful, safe and lightweight scripting language and engine for .NET
Stars: ✭ 1,360 (+1082.61%)
Mutual labels:  liquid
Hanuman
A responsive, lightning-fast Jekyll theme built using AMP (Accelerated Mobile Pages) to speed up your blogs and websites.
Stars: ✭ 100 (-13.04%)
Mutual labels:  jekyll
Kmeans pytorch
kmeans using PyTorch
Stars: ✭ 98 (-14.78%)
Mutual labels:  jekyll

Jekyll Menus

A robust, simple-to-use menu plugin for Jekyll that allows for infinitely nested menus.

Installation

To install and use Jekyll Menus, you should have Ruby, and either RubyGems, or we recommend using Bundler. Bundler is what Jekyll will prefer you to use by default if you jekyll new.

Using Bundler

You can add our gem to the jekyll_plugins group in your Gemfile:

group :jekyll_plugins do
   gem "jekyll-menus"
end

And then install from shell.

bundle install
   # --path vendor/bundle

If you are using Jekyll Docker, you do not need to perform this step, Jekyll Docker will perform it on your behalf when you launch the image, you only need to perform this step if you are working directly on your system.

Using RubyGems

sudo gem install jekyll-menus
sudo gem update  jekyll-menus

Once installed, add the Gem to your _config.yml:

plugins:
- jekyll-menus

Note in earlier versions of Jekyll, plugins should instead be gems

Usage

Jekyll Menus allows you to create menus by attaching posts and pages to menus through their front matter, or by defining custom menu items via _data/menus.yml.

Jekyll Menus adds a new option to the site variable called site.menus, which can be looped over just like pages, posts, and other content:

<ul>
{% for item in site.menus.header %}
  <li class="menu-item-{{ loop.index }}">
    <a href="{{ item.url }}" title="Go to {{ item.title }}">{{ item.title }}</a>
  </li>
{% endfor %}
</ul>

Menus via Front Matter

The easiest way to use Jekyll Menus is to start building menus using your existing posts and pages. This can be done by adding a menus variable to your front matter:

---
title: Homepage
menus: header
---

This will create the header menu with a single item, the homepage. The url, title, and identifier for the homepage menu item will be automatically generated from the pages title, file path, and permalink.

You can optionally set any of the available menu item variables yourself to customize the appearance and functionality of your menus. For example, to set a custom title and weight:

---
title: Homepage
menus:
  header:
    title: Home
    weight: 1
---

Custom Menu Items via _data/menus.yml

The other option for configuring menus is creating menus using _data/menus.yml. In this scenario, you can add custom menu items to external content, or site content that isn’t handled by Jekyll.

In this file, you provide the menu key and an array of custom menu items. Custom menu items in the data file must have url, title, and identifier variable:

---
header:
  - url: /api
    title: API Documentation
    identifier: api
---

Sub-menus

Jekyll Menus supports infinitely nested menu items using the identifier variable. Any menu item can be used as a parent menu by using its identifier as the menu.

For example, in _data/menus.yml:

header:
  - url: /api
    title: API Documentation
    identifier: api

In a content file called /api-support.html:

---
title: Get API Support
menus: api
---

Which can then be used in your templates by looping over the menu item’s children variable:

<ul>
{% for item in site.menus.header %}
  <li class="menu-item-{{ loop.index }}">
    <a href="{{ item.url }}" title="Go to {{ item.title }}">{{ item.title }}</a>
    {% if item.children %}
      <ul class="sub-menu">
      {% for item in item.children %}
        <li class="menu-item-{{ loop.index }}">
          <a href="{{ item.url }}" title="Go to {{ item.title }}">{{ item.title }}</a>
        </li>
      {% endfor %}
      </ul>
    {% endif %}
  </li>
{% endfor %}
</ul>

You can also do this recursively using a re-usable include, allowing for easily managed infinitely nested menus.

Variables

Jekyll Menus has the following variables:

Menus

Variable Description
menu.menu Returns a JSON object with all of the menu’s items.
menu.identifier The unique identifier for the current menu, generated from the menu key. Allows for nested menu items.
menu.parent The parent menu. Resolves to the site.menus object for top-level menus.

Menu Items

Variable Description
item.title The display title of the menu item. Automatically set as the post or page title if no value is provided in front matter.
item.url The URL the menu item links to. Automatically set to the post or page URL if no value is provided in front matter.
item.weight Handles the order of menu items through a weighted system, starting with 1 being first.
item.identifier The unique identifier for the current menu item. Allows for nested menu items. Automatically resolved to the page’s file path and filename if not provided in front matter.
item.parent The parent menu.
item.children An array of any child menu items. Used to create sub-menus.

Custom Variables

Menu items also support custom variables, which you add to each menu item in the front matter or data file.

For example, adding a pre or post variable to add text or HTML to your menu items:

---
title: Homepage
menus:
  header:
    pre: <i class="icon-home"></i>
    post: " · "
---

Recursive Menus

If you’re looking to build an infinitely nested menu (or a menu that is nested more than once up to a limit) then you should set up a reusable menu include that will handle this for you.

In _includes/menu.html :

{% if menu %}
<ul>
{% for item in menu %}
  <li class="menu-item-{{ loop.index }}">
    <a href="{{ item.url }}" title="Go to {{ item.title }}">{{ item.title }}</a>
    {% if item.children %}
      {% assign menu = item.children %}
      {% include menu.html %}
    {% endif %}
  </li>
{% endfor %}
</ul>
{% endif %}

In _layouts/default.html (or any layout file):

<html>
  <body>
    <header>
      <nav>
        {% assign menu = site.menus.header %}
        {% include menus.html %}
      </nav>
    </header>
    {{ content }}
  </body>
</html>
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].