Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/niklasei/jekyll_custom_permalink
Jekyll plugin adding support for any Front Matter in permalinks
https://github.com/niklasei/jekyll_custom_permalink
jekyll jekyll-plugin
Last synced: about 2 months ago
JSON representation
Jekyll plugin adding support for any Front Matter in permalinks
- Host: GitHub
- URL: https://github.com/niklasei/jekyll_custom_permalink
- Owner: NiklasEi
- License: mit
- Created: 2019-04-27T19:16:13.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-04-13T08:02:14.000Z (9 months ago)
- Last Synced: 2024-11-02T10:31:57.771Z (about 2 months ago)
- Topics: jekyll, jekyll-plugin
- Language: Ruby
- Homepage:
- Size: 6.84 KB
- Stars: 8
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Jekyll custom permalink
[![Gem Version](https://badge.fury.io/rb/jekyll_custom_permalink.svg)](https://badge.fury.io/rb/jekyll_custom_permalink)
This Jekyll plugin allows you to use custom Front Matter in the `permalink` setting of collections.
## Installation
Add the plugin to your site's Gemfile:
```ruby
group :jekyll_plugins do
# your other jekyll plugins...
gem 'jekyll_custom_permalink', '~> 0.0'
end
```Then run
```bash
$ bundle install
```## Usage
Lets assume that you have some options for your collection "projects" defined in `_config`:
```yml
collections:
projects:
output: true
permalink: projects/:title/
```You would like to use custom Front Matter in the paths of your projects. For example, it would be great to be able to include the Front Matter variable `type` in the links to your projects, which is defined in every file belonging to the "projects" collection.
```yml
---
layout: page
type: python
title: MyAwesomeProject
---
Some content
```You can use the `type` variable in your permalink by first adding it to an array of custom permalink placeholders for the collection, and then adding the placeholder to the permalink setting prefixed with a `:` like every other Jekyll placeholder.
```yml
collections:
projects:
output: true
custom_permalink_placeholders: ["type"]
permalink: projects/:type/:title/
```
These settings lead to the "project" page, shown above, to be live at `/projects/python/MyAwesomeProject`.If the variable is not defined, it is ignored for the permalink. Meaning `projects/:type/:title/` will be like `projects/:title/` for a document without `type` set in its Front Matter. This is the same behaviour as for the default Jekyll placeholders.