Skip to content

Latest commit

 

History

History
71 lines (50 loc) · 1.98 KB

README.md

File metadata and controls

71 lines (50 loc) · 1.98 KB

jekyll-placeholders

Build Status

This gem makes Jekyll a little more self-aware. By default, Jekyll's support for defining collection permalinks is limited to a few placeholder values. When building complex layouts with nested URLs, this gem exposes any key/value pair defined in document frontmatter such that you can use them when defining your collection permalinks.

Installation

Add the following to your Gemfile and bundle...

gem "jekyll-placeholders", "~> 0.0.1", git: 'https://github.com/ample/jekyll-placeholders.git'

Usage

Let's assume we have the following document frontmatter within our collections directory...

---
title: Some Article
slug: some-article
category_slug: some-category
layout: default
---

Our collections configuration looks like this...

collections:
  articles:
    output: true
    permalink: /articles/:category_slug/:slug

When the project is built, the document referenced above will be rendered to the following path...

http://localhost:4000/articles/some-category/some-article

Deeply Nested Frontmatter

This gem even supports deeply nested references, where needed. Imagine the following frontmatter where categories is an array of objects...

---
title: Some Article
slug: some-article
categories:
  - title: Some Category
    slug: some-category
layout: default
---

You can achieve the same result by configuring your collection permalink, like this...

collections:
  articles:
    output: true
    permalink: /articles/(:categories/:0/:slug)/:slug

When the project is built, the document referenced above will be rendered to the following path...

http://localhost:4000/articles/some-category/some-article

License

This project is licensed under the 3-Clause BSD License.