Top Contributors
-
matthewowen - 2
-
cnunciato - 2
-
LawrenceWoodman - 2
-
tsmango - 2
-
stereobooster - 2
Most Forked
- jekyll_alias_generator - 32
- jekyll-tagging - 30
- jekyll-scholar - 18
- jekyll-tweet-tag - 18
- jekyll-asset_bundler - 18
Most Watched
- jekyll-author-plugin - 10
- Simple-Jekyll-Search - 9
- jekyll-press - 9
- jekyll-scholar - 9
- jekyll_alias_generator - 8
Most Starred
- Simple-Jekyll-Search - 244
- jekyll-scholar - 176
- jekyll-tagging - 104
- jekyll_alias_generator - 102
- jekyll_indextank - 90
Plugin Information
README.md
h1. Jekyll Data Pages Generator
Jekyll allows data to be specified in YAML format in the @_data@ dir.
If the data is an array, it is straightforward to build an index page, containing all records, using a Liquid for loop. In some occasions, however, you also want to generate one page per record. Consider, e.g., a list of team members, for which you want to generate an individual page for each member.
This generator allows one to specify data files for which we want to generate one page per record.
Among the advantages:
- general purpose: it works with any array of data: people, projects, events, ... you name it
- it manages multiple data sources in the same website
h1. Installation
Download @data_page_generator.rb@ and put it in the @_plugins@ directory of your website.
h1. Usage
- Specify in @_config.yml@ the data files for which you want individual page to be generated.
- Launch Jekyll
The specification in config.yml is as follows:
data_gen: - data: <> template: < > name: < > dir: < > - ...
where:
- @data@ := is the name of the file to read
- @name@ := is the name of a field which contains a unique identifier that can be used to generate a filename
- @template@ := is the name of a template to generate the pages (it defaults to the value of @data@ + ".html"). Optional, if not set, the generator uses the value of the @data@ field
- @dir@ := is the directory where pages are generated (it defaults to the value of @data@). Optional, if not specified, the generator uses the value of the @data@ field.
More than one data source can be specified: the generator iterates over each element of the @data_gen@ array.
A liquid tag is also made available to generate a link to a given page. For instance:
{{ page_name | data_page_url: dir }}
generates a link to @page_name@ in @dir@.
h1. Example
- You have an @member.yml@ file stored in the @_data@ directory of your Jekyll website, with the following content:
- name: adolfo villafiorita bio: long bio goes here - name: pietro molini bio: another long bio - name: aaron ciaghi bio: another very long bio
- There is a @profile.html@ file stored in the @_layouts@ directory:
{{page.name}}
{{page.bio}}
- @_config.yml@ contains the following:
page_gen: - data: 'member' template: 'profile' name: 'name' dir: 'people'
Then, when building the site, this generator will create a directory @people@ containing, for each record in @member.yml@, a file with the record data formatted according to the @profile.html@ layout. The record used to generate the filename of each page is @name@.
$ cd example $ jekyll build $ cat _site/people/adolfo_villafiorita.htmlAdolfo Villafiorita
long bio goes here
Check the example directory for a live demo. (Notice that the ruby file in @_plugins@ is a symbolic link; you might have to removethe link and manually copy the ruby file in the @_plugins@ directory, if symbolic links do not work in your system.)
h1. Author
Adolfo Villafiorita
h1. Known Bugs
No known bugs; unknown number of unknown bugs.
h1. License
Distributed under the terms of the "MIT License":http://opensource.org/licenses/MIT