Git Product home page Git Product logo

jekyll-datapage_gen's Introduction

README

Jekyll Data Pages Generator

Jekyll allows data to be specified in YAML, CSV, and JSON 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 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

Installation

Option 1. Add =gem “jekyll-datapage-generator”= to your project Gemfile and then load it as a plugin in the configuration:

plugins:
  - jekyll-datapage-generator

(See https://jekyllrb.com/docs/plugins/installation/ for more details.)

Option 2. Download jekyll-datapage-generator.rb and put it in the _plugins directory of your website. Remember to delete older versions of the source file from the =_plugins= directory or you might run into errors.

Quick Start

Read the example section or the included example to get started quickly.

Usage

You have some data in a data file for which you want to generate individual pages.

  1. Specify in _config.yml the data file(s) for which you want to generate individual pages
  2. Define in _layouts the layout Jekyll will use to generate the individual pages
  3. Launch Jekyll

The specification in config.yml looks like:

page_gen-dirs: [true|false]

page_gen:
- data: [name of a data set in _data]
  template: [name of template in _layouts: will be used to render pages]
  dir: [directory where filenames will be generated]
  index_files: [true|false]
  name: [field used to generate the filename]
  name_expr: [a Ruby expression to generate the filename (alternative to name)]
  title: [field used to generate the page title]
  title_expr: [a Ruby expression to generate the filename (alternative to title)]
  extension: [extension used to generate the filename]
  filter: [property to filter data records by]
  filter_condition: [a Ruby expression to filter data]
  page_data_prefix: [prefix used to name variables]
  debug: [boolean, if true output more informative messages]
  
[another set of data, if you want ...]

where:

  • page_gen-dirs specifies whether we want to generate named folders (true) or not (false) for all generated data.
  • page_gen is an array specifying a data for which individual pages have to be generated.

Each entry in page_gen can (in some cases must) contain the following fields:

  • data is the name of the data file to read (YAML, Json, or CSV). Use the full path, if your data is structured in a hierarchy. For instance: hierarchy.people will loop over the variable people in the _data/hierarchy.yml file.
  • template is the name of a template used to layout data in the page. Optional, if not specified, the plugin uses the layout with the same name of the value of ~data~.
  • dir is the directory where pages are generated. Optional: if not specified, the generator puts pages in a directory with the same name of the value of the ~data~ field.
  • name is the name of a field in the data used to generate a filename. You need to ensure values in the chosen field are unique, or some files will get overwritten.
  • name_expr is an optional Ruby expression used to generate a filename. The expression can reference fields of the data being read using the record hash (e.g., record['first_name'] + "_" + record['last_name']; see the documentation of filter_condition for more details.) Optional: used in alternative to ~name~. If set it overrides ~name~
  • index_files specifies whether we want to generate named folders (true) or not (false) for the current set of data. Optional: if specified, it overrides the value of the global declaration ~page_gen-dirs~.
  • title is the name of a field in data which is used for the page title. Optional: if not specified, the generator uses the filename as the page title.
  • title_expr is an optional Ruby expression used to generate the page title. The expression can reference fields of the data being read using the record hash (e.g., record['first_name'] + "_" + record['last_name']). Optional, but if set, it overrides ~title~.
  • extension is the extension of the generated files. Optional: if not specified, the generator uses ~html~ extension.
  • page_data_prefix is the prefix used to output the page data. Data read from each record is made available in the page so that it can be accessed using liquid tags. In some cases, however, there might be clashes with existing tags. page_data_prefix can be used to prefix all data read from records and avoid the problem mentioned above. Optional: if not specified, no prefix is used.
  • filter is a property of each data record that must return a true-ish value for the record to be included in the list of files to be generated. See Filtering Data, below, for more details. Optional: if not specified, all records from the dataset are included (see also ~filter_condition~).
  • filter_condition is a string containing a Ruby expression which evaluates to a true-ish value. The condition can reference fields of the data being read using the record hash (e.g., record['author'] ~ ‘George Orwell’~). See Filtering Data, below, for more details. Optional: if not specified, all records from the dataset are included (see also ~filter~).
  • debug is a Boolean value specifying whether the plugin will output information about the configuration and data read. Optional: if not specified, no debug information is outputted.

Note. The same data structure can be referenced different times, maybe with different target directories. This is useful to group pages in different directories, using filter_condition.

A liquid tag is also made available to generate a link to a given page. For instance:

{{ page_name | datapage_url: dir }}

generates a link to page_name in dir.

Filtering Data

There are three different ways which you can use to show only the relevant records of a data structure in your website:

Do not link uninteresting pages

Generate pages for all records (relevant and not), but link only the interesting pages.

The uninteresting pages will still get generated but will not be easily accessible. A visitor has to guess the URL to access them. This is more of a workaround, rather than a solution.

This is shown in the books.md file, in the section “Books I have read”.

The filter is applied to the links to tha generated pages. Pages will still be generated for all books, but only those for which book.read is true will be easily accessible (since only these have an explicit link in our website).

Use the filter condition

Use the filter property.

In this case, all records in your data structure should have a boolean field, let us say, publish. Pages will be generated only for those records in which the publish field is true(-ish).

Consider the following declaration in _config.yml:

- data: 'books'
  template: 'book'
  name: 'title'
  dir: 'books-i-have-read'
  filter: read  # read is a boolean value in the YML file

In this case, a page will be generated only for the books in which the field read is true.

Use the filter_condition condition

Use the filter_condition property.

The field should contain a string which evaluates to a boolean expression. The string may reference fields of the data structure using the record[<field_name>] notation, like, for instance in record['author'] ~ ‘George Orwell’~.

In this case pages will be generated only for the records satisfying the evaluation of the filter_condition.

Example 1. Consider the following declaration in _config.yml:

- data: 'books'
  template: 'book'
  name: 'title'
  dir: 'books-i-have-not-read'
  filter_condition: "record['read'] ~~ false"

that allows me to generate a list of the books I have not read. The filter keyword, in this case, is no good, since I need to test for falsity (read has to be false).

The filter condition allows to select only those records in which record['read'] is false.

Remark If you want to filter on nested fields, use multiple []. For instance:

filter_condition: "record['did-i']['read'] ~~ false"

works with the following data structure:

- author: Harper Lee
  title: To Kill a Mockingbird
  did-i:
    read: no
  rating: 4.26
  year: 1960
  position: 1

Example 2. Consider the following declaration in _config.yml:

- data: 'books'
  template: 'book'
  name: 'title'
  dir: 'books-by-orwell'
  filter_condition: "record['author'] ~~ 'George Orwell'"

In this case, I am testing the author field and generating pages only for the books by George Orwell.

As a final consideration, filter_condition allows one to deploy pages in different directories according to specific properties.

Consider the following example:

- data: 'books'
  template: 'book'
  name: 'title'
  dir: 'books-read'
  filter_condition: "record['read'] ~~ true"
- data: 'books'
  template: 'book'
  name: 'title'
  dir: 'books-to-read'
  filter_condition: "record['read'] ~~ false"

which splits the book data structure in two different folders, according to the value of the read flag.

Of course, such an approach makes sense only for variables with a limited number of values, since one needs to explicitly specify in _config.yml conditions and target directories.

Generating Filename with an Expression

You can generate filenames with an expression, by replacing name with name_expr. For example, if you have data in a .yml file that looks like this:

- first_name: adolfo
  last_name: villafiorita
  bio: long bio goes here
- first_name: pietro
  last_name: molini
  bio: another long bio
- first_name: aaron
  last_name: ciaghi
  bio: another very long bio

Your _config.yml could contain the following:

page_gen:
  - data: 'members'
    template: 'profile'
    name_expr: record['first_name'] + "_" + record['last_name']
    dir: 'people'

Example

  1. You have a members.yml file in the _data directory, 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

Alternatively, you could have a members.json (or a members.csv file) stored in the _data directory with the following content and the example would work the same:

[
  {
    "name": "adolfo villafiorita",
    "bio": "long bio goes here"
  },
  {
    "name": "pietro molini",
    "bio": "another long bio"
  },
  {
    "name": "aaron ciaghi",
    "bio": "another very long bio"
  }
]
  1. There is a profile.html file in the _layouts directory:
<h1>{{page.name}}</h1>

{{page.bio}}
  1. _config.yml contains the following:
page_gen:
- data: 'members'
  template: 'profile'
  name: 'name'
  dir: 'people'

Then, when building the site, this generator will create a directory people containing, for each record in members.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, sanitized.

$ cd example
$ jekyll build
$ cat _site/people/adolfo-villafiorita.html
<h1>Adolfo Villafiorita</h1>

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 remove the link and manually copy the ruby file in the _plugins directory, if symbolic links do not work in your system.)

Change Log

See the CHANGELOG file.

Compatibility

Run successfully at least once with the following Jekyll versions: 4.2.1., 4.0.1, 3.8.5, 3.6.2, 3.1.6. Try with the included example and open an issue if you find any compatibility issue.

Author and Contributors

Adolfo Villafiorita with several excellent contributions from various authors.

Known Bugs

Some known bugs and an unknown number of unknown bugs.

(See the open issues for the known bugs.)

License

Distributed under the terms of the MIT License.

jekyll-datapage_gen's People

Contributors

albertvolkman avatar atlas48 avatar avillafiorita avatar bsalinas avatar danieljdufour avatar davidpots avatar dependabot[bot] avatar getfol avatar jbleuzen avatar jferreira-godaddy avatar ketrel avatar kjbrum avatar marceloverdijk avatar mjenczmyk avatar rgegriff avatar vidhyav656 avatar y0m0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jekyll-datapage_gen's Issues

Use includes in data

I am trying to use includes inside posts for specific content blocks. When I am testing I just see the include displayed as a string:
{% include components/blockquote.html copy="This is a test blockquote" %}

Is it possible to use includes with page_gen and if so how do I get it to not render as a string?

jekyll pagemapper

i got the error jekyll 3.7.0 | Error: undefined method `gsub' for #Hash:0x000000058f0318 on rake build command, and the following is my _config.yml file contents:
_config.txt

CSV as input?

Wondering how difficult it would be to accept csv as the input format?
Or in other words, should I start trying to figure it out or should I stop and find an alternative solution (like scripting a conversion to yml)

Cannot do groups in generated pages

I used this plugin to create a staff directory. It has been absolutely flawless, but I was hoping to extend it to be able to create individual pages of grouped items.

So far I can make a page for each staff member, but I was hoping to also make a page for each state, and have every staff member within the state show. When I try to do that, it only shows one staff member from that state, and their associated data is all broken.

Error when layout is a markdown file

If the layout file specified in _config.yml is a .md file, I get the following error:

$ jekyll build --trace
Configuration file: /Users/Project/tilefarm_html/_config.yml
            Source: /Users/Project/tilefarm_html
       Destination: /Users/Project/tilefarm_html/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
error. could not find template workshop.md
                    done in 0.613 seconds.
 Auto-regeneration: disabled. Use --watch to enable.

I get no errors if I rename the .md file to .html (but the markdown does not get rendered by Jekyll).

Relevant field from _config.yml:

# Markdown config
markdown: kramdown
kramdown:
  parse_block_html: true

# Page generator https://github.com/avillafiorita/jekyll-datapage_gen
page_gen:
  - data: test
    template: workshop.md
    name: filename
    dir: /pages/workshops/
    extension: md

Generated file can't be a number

If my name attribute is a number the plugin fail to generate content.
Here is the error I get :

jekyll 2.5.3 | Error:  undefined method `downcase' for 1:Fixnum

Generate pages with multi-level path

Let's say I want to generate pages on the following URLs:
/animal/mammal/1/whale
/animal/mammal/2/tiger
/animal/reptile/3/snake

The directory pattern would have to be /animal/{group}/{id}/{name} where input data is an array of animals. The directory does not support patterns.

I have tried to create an object property with the value /animal/mammal/1/whale. That doesn't work either, pages are placed in the folder animalmammal1whale, i.e., slashes are stripped.

Question from a noob to your plugin...

What is the difference between this plugin and jekyll collections:

https://jekyllrb.com/docs/collections/

Someone who works at cloudcannon was corresponding with me and said the following about your plugin:

I think I've seen that plugin before but have never had a use case for it not handled already by Jekyll collections.

But i feel like the strength of yours is primarily found in building nearly everything with json, as well as being able to do more complicated includes.

RFE: using datapage_gen fields at Front Matter

For example, you have a table with two fields for the planes.csv data file:

model, name
b787, "Boeing B787 Dreamliner"
a320, "Airbus 320"

Actual situation:

Now you can index the data according the model field, thus generating simple meaningful filenames. But in the model field is automatically used as the final html title, which can be, as in this case, very human friendly.

Proposal:

At the layout's front matter, being able to use datagen_gen fields as properties. For example:

---
layout: planes
title: {{ planes.name }}
---

I thik can be really useful and easy to use.

Thanks in advance.

NoMethodError: undefined method `tr' for nil:NilClass

Hi:

First all thankyou very much for your plugin. It could solve exactly the problem for my project.

I'm using your last plugin version at the repo. I verified your example runs in my system but when using in my project I got this error:

$ bundle exec jekyll serve --trace
Configuration file: /home/olea/13framework-TFG/webo-29110/_config.yml
            Source: /home/olea/13framework-TFG/webo-29110
       Destination: /home/olea/13framework-TFG/webo-29110/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
bundler: failed to load command: jekyll (/home/olea/.gem/bin/jekyll)
NoMethodError: undefined method `tr' for nil:NilClass
  /home/olea/13framework-TFG/webo-29110/_plugins/data_page_generator.rb:14:in `sanitize_filename'
  /home/olea/13framework-TFG/webo-29110/_plugins/data_page_generator.rb:42:in `initialize'
  /home/olea/13framework-TFG/webo-29110/_plugins/data_page_generator.rb:98:in `new'
  /home/olea/13framework-TFG/webo-29110/_plugins/data_page_generator.rb:98:in `block (2 levels) in generate'
  /home/olea/13framework-TFG/webo-29110/_plugins/data_page_generator.rb:97:in `each'
  /home/olea/13framework-TFG/webo-29110/_plugins/data_page_generator.rb:97:in `block in generate'
  /home/olea/13framework-TFG/webo-29110/_plugins/data_page_generator.rb:72:in `each'
  /home/olea/13framework-TFG/webo-29110/_plugins/data_page_generator.rb:72:in `generate'
  /home/olea/.gem/gems/jekyll-3.8.4/lib/jekyll/site.rb:175:in `block in generate'
  /home/olea/.gem/gems/jekyll-3.8.4/lib/jekyll/site.rb:173:in `each'
  /home/olea/.gem/gems/jekyll-3.8.4/lib/jekyll/site.rb:173:in `generate'
  /home/olea/.gem/gems/jekyll-3.8.4/lib/jekyll/site.rb:70:in `process'
  /home/olea/.gem/gems/jekyll-3.8.4/lib/jekyll/command.rb:28:in `process_site'
  /home/olea/.gem/gems/jekyll-3.8.4/lib/jekyll/commands/build.rb:65:in `build'
  /home/olea/.gem/gems/jekyll-3.8.4/lib/jekyll/commands/build.rb:36:in `process'
  /home/olea/.gem/gems/jekyll-3.8.4/lib/jekyll/commands/serve.rb:93:in `block in start'
  /home/olea/.gem/gems/jekyll-3.8.4/lib/jekyll/commands/serve.rb:93:in `each'
  /home/olea/.gem/gems/jekyll-3.8.4/lib/jekyll/commands/serve.rb:93:in `start'
  /home/olea/.gem/gems/jekyll-3.8.4/lib/jekyll/commands/serve.rb:75:in `block (2 levels) in init_with_program'
  /home/olea/.gem/ruby/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
  /home/olea/.gem/ruby/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
  /home/olea/.gem/ruby/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
  /home/olea/.gem/ruby/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
  /home/olea/.gem/ruby/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
  /home/olea/.gem/gems/jekyll-3.8.4/exe/jekyll:15:in `<top (required)>'
  /home/olea/.gem/bin/jekyll:23:in `load'
  /home/olea/.gem/bin/jekyll:23:in `<top (required)>

Enviroment:

$ bundle exec jekyll --version; bundle exec  ruby --version
jekyll 3.8.4
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]

After several tries I discarded a plugin or configuration conflict. Or a bug in my layout. My main suspect is the _data/29110.csv file, but I can't really diagnose what the problem is. Things I know:

  • I even tried to use my _config.yml and Gemfiles with your example/ to look for conflicts but it ran smoothly
  • csv file is generated from a LibreOffice sheet
  • csv works fine with the data files jekyll feature
  • I tried without success modified versions of the csv file:
    • removing columns
    • exporting fields qouted

I ran out of ideas and don't know ruby so I can't deep investigating-

Any suggestion?
Thanks in advance.

PS: If you want to check my project you can download it: http://olea.org/tmp/webo-29110.zip

jekyll 3.7.2 | Error: no implicit conversion of Integer into String

Configuration file: /Users/usr/Documents/jekyll/my/_config.yml
            Source: /Users/usr/Documents/jekyll/my
       Destination: /Users/usr/Documents/jekyll/my/_site
 Incremental build: enabled
      Generating...
  Liquid Exception: no implicit conversion of Integer into String in /_layouts/post.html
jekyll 3.7.2 | Error:  no implicit conversion of Integer into String

I used your example files because I want to see the preview but I got this when trying to run it.
The gem version is 2.7.4

Generate nicer URLs

Hi, currently if you use a title string, such as "The Awesome Photo", for the name key, the resulting directory structure is The_Awesome_Photo/index.html. It would be more friendly to generate the-awesome-photo/index.html.

Error

Hi i used your plugin but its giving me this error:

D:\Gelo Files\Github\vcsites>jekyll build
WARN: Unresolved specs during Gem::Specification.reset:
rb-inotify (>= 0.9.7, ~> 0.9)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
Configuration file: D:/Gelo Files/Github/vcsites/_config.yml
Source: D:/Gelo Files/Github/vcsites
Destination: D:/Gelo Files/Github/vcsites/_site
Incremental build: disabled. Enable with --incremental
Generating...
jekyll 3.4.0 | Error: undefined method `downcase' for nil:NilClass

Nested layouts results in a duplicate content

I have a layout called map.html with front matter:

---
layout: default
---

Including my {{ page.foo }} data in it prints the data twice. When I just add it to default.html, the data is printed correctly just once.

I want to get data in _includes/hero.html from _data/member.yml

Hello, Firstly thanks for share nice plugin...

According to your example I want to include file in your profile.html from _includes/hero.html
like - {% include hero.html %}

in hero.html - How I get data from _data/member.yml
I try this in my _includes/hero.html

{{ site.data.member[full_name] }}

but its not working so please help me out.

Thanks in advance !!!

Message "Configuration file: [...]/_config.yml" repeated over and over in console

When generating a website using this plugin, my console gets flooded with this message (I removed the full path from it)

I'm not too sure what triggers it, wether it's the collection itself, or if it's the datapage_url liquid filter provided by the plugin (BTW I discovered it by chance, it's not in the docs IIRC). I use the filter a lot due to how it allows me to link generated pages from other pages.

You can take a look at the jekyll site in question if you want to try it out : https://lab.shelter.moe/karaokemugen/sites/mugen-site

This is not a particularly big bug but it's kind of annoying :)

Generate .md pages to root?

Hello, and thank you so much for your incredibly helpful plugin!

I've been trying (unsuccessfully) for a few hours to augment the plugin to generate the directory and pages to the root folder as markdown instead of pre-rendered as html within the _site folder. I thought this would be relatively trivial. Is there something I'm missing?

i.e., for _config.yml:

page_gen:
   - data: 'image'
     template: 'image-page'
     name: 'title'
     dir: 'collection'
     extension: 'md'

I need:

+-- _data
|   +--image.yml
+-- _includes
+-- _layouts
+-- _collection
|   +--page-example1.md
|   +--page-example2.md
|   +--...
+-- _config.yml
+-- Gemfile

where the front matter of each .md page is pulled from the initial _data/image.yml.

(This seems to be exactly what happens on jekyll build, except that the .md files aren't kept anywhere.) Any thoughts? Do I need to integrate the plugin to work with Jekyll collections?

Thanks!

Wrong subdirectory when generating links in subdir

Hi,

the title might be a little confusing or misleading, however, I found a potential bug in this excellent plugin.

For instance, I created a subdirectory called inktober, created an index.html file there with the following content:

---
layout: default
---

<section class="section">
    <div class="container">
        {% for image in site.data.inktober %}
        <article class="media">
            <div class="media-content">
                <div class="content">
                    <p class="is-size-3 title"><strong><a href="{{ image.title | datapage_url: 'inktober' }}">{{ image.title }}</a></strong></p>
                    <p class="subtitle is-size-6">Veröffentlicht am: {{ image.date }}</p>
                </div>
            </div>
        </article>
        {% endfor %}
    </div>
</section>

Now, when building the website it will create links to /inktober/inktober/whatevertitle/. Calling the same code from a file called /inktober.html (in the website root), the links to the corresponding links are correct set as /inktober/whatevertitle/. Means that the link creating expects that the caller for reading the data resides in the webroot directory of the site, or it will add the subdirectory of the caller as well.

Since I'm not a Ruby programmer, I can't provide a fix for this right now. I can just report it.

Regards, Thomas

If template is found: Error: undefined method `split' for nil:NilClass

First of all, thank you for writing this plugin, I've been looking high and low for something like this.

However i fail to put it to proper use.

With jekyll 3.8.3 if i enter a valid layout name in _config.yml, jekyll gives me the aforementioned error and exits.

If i enter a bogus layout name, jekyll will complain about a missing template but run successfully, although obviously no pages are generated.

Content of _config.yml:

page_gen:
  - data: releases
    template: album
    name: releases.title
    dir: records

Content of layout in _layouts/album.html

{{ page.title }}

Content of _data/releases.yml

- 
  archive: "https://archive.org/details/BPIST013"
  artist: tfb
  coverart: 
    art: "TFB-OTK.png"
    thumb: "TFB-OTK.png"
  description: "Enter this cybernetic opus of oblivion and computer aided overstanding, grown somewhere beyond the laws of physics.<br />From earth to your folder, we send you vibrant energy, defying the relative time of life. We wanted to hand you the key to inner-space and Invite you to Enter:<br />THE FRAGLEBAY<br />ON THE KEYBOARD<br />ON THE KEYBOARD<br />on the keyboard<br />on the keyb<br /><br />Stay Fragle!"
  title: "TFB - OTK"
- 
  archive: "https://archive.org/details/BPIST011"
  artist: franky
  coverart: 
    art: "DustAndSoda.jpg"
    thumb: "DustAndSoda.jpg"
  description: "Dust And Soda is radical disco by young Mexican producer, Franky Fresco."
  title: "Dust And Soda"

Pretty sure it's me doing something wrong, but i've run out of ways to find it out by myself. Hopefully someone can point me in a good direction.

Thanks for your time,
*Set

Hierachy differences option

Hi!
I'm importing some data from Contentful CMS which all ends down in a yaml file with a little bit different structure than the one in your example.
I've been trying to figure out how I can get your script to work if my yaml hierachy is different.

Your YAML file

- full_name: adolfo villafiorita
  first_name: adolfo
  bio: long bio goes here
- full_name: pietro molini
  first_name: pietro
  bio: another long bio
- full_name: aaron ciaghi
  first_name: aaron
  bio: another very long bio
My YAML file

page:
- sys:
    id: 2ss8tkwNri0sCmIO22EIeK
  title: Foo
  body: "Some content in a body field"
- sys:
    id: 2ss8tkwNrisdferasdfO22EIeK
  title: Bar
  body: "Some content in a body field"

Can I somehow change the config file to match the structure of the yaml file?

Your config file

page_gen-dirs: true # uncomment, if you prefer to generate named folders
page_gen:
  - data: 'member'
    template: 'profile'
    name: 'full_name'
    dir: 'people'
My config file

page_gen-dirs: true # uncomment, if you prefer to generate named folders
page_gen:
  - data: 'contentful.spaces.nets'
    template: 'accordion'
    name: 'page'
    dir: 'pages'

Maybe something like "page.sys.id"
In the data you can set it to descent into the folders.
Is there a feature like that with the yaml file?

If I paste your yaml content into my yaml it works and generates the pages perfectly, but with the generated yaml file and your script it fails with this error message:
"jekyll 3.2.1 | Error: no implicit conversion of String into Integer"

Thanks you in advance!

Problem with local variable

Hi!
When i tring build my jekyll project, I get error:
jekyll 2.5.3 | Error: undefined local variable or method `data_file' for #

Can You help me with that?

Linking auto generated links

Page linking is not working on me.

_config.yml

page_gen-dirs: true
page_gen:

  • data: 'vclist'
    template: 'profile'
    name: 'Name'
    dir: 'vclist'

CODE:

    {% for list in site.data.vclist %}
  • {{list.Name}}
  • {% endfor %}

Example of filter option

First of all this is a great plugin!

I have tried to find an example of the filter option but to no avail.

How would I use the filter option if I am trying to generate pages where the a record property value is 'example_category' ? or is it that it just exists? I am sure soon as I see an example I will understand it a lot more.

Essentially I want to generate pages only with a certain category value

Compatibility

Hey, is this compatible with Jekyll 3?

Might be worth adding a mention of compatibility to the readme (appologies if it is already there and I have missed it :)

Is it possible to have arrays in a field that I can loop over?

So I have a field called slideshow with the array [image1.jpg,image2.jpg,image3.jpg] and want to loop over these {% for slide in page.slideshow %} which would work if these were in the page front matter, but does not work if they are an entry in my csv file. Ideas?

Thanks for an awesome plugin!

Undefined method

After adding the plugin and adding the requisite config values, I get this on jekyll serve-

jekyll 3.1.2 | Error: undefined method each' for nil:NilClass`

Am I missing something?

Is it possible to iterate at the same file?

I have a people.yml file with information about researchers from a laboratory. In that file there are supervisors and students.

I would like to put students names in the supervisor page. I am trying to iterate in people.yml file again when generating the supervisor pages, but looks like it is not possible. None information is returned.

Well, is there a way to iterate in that file again while generate pages from it?

Generating index.html files

When I use this script, I end up with a directory layout like this:

pets
- dog.html
- cat.html

Is there a way to generate this instead?

pets
- dog
  - index.html
- cat
  - index.html

Thanks!

Jekyll 3 Layout vs Page metadata

Jekyll 3 provides a layout variable (see this) that is separate from the page variable. Right now, it seems like this plugin doesn't respect that, and just merges the two together, breaking my existing layouts/includes that are dependent on that variable.

How to parse 3 level objects?

The example shows how to parse a data file and a property in the items. For example a list of books.

What if I want to have a list of book categories, with each category having a list of books, and generate pages for each book with the following folder structure?

category-id/book-id/index.html

Data member 'name' clash

If the data entries have a member 'name', it will be inaccessible because page.name will refer to the Jekyll page objects name. Likewise title, etc

Don't delete the dot (and other character) in the filename

Thanks for your simple and great plugin!

I think the next will be useful: user can define which characters shouldn't delete at generate from filename in sanitaze_filename. In my case: my layout works with own filename to determine which image should appear (e.g. pict1.jpg.html with layout pict will display pict1.jpg - remove the .html extension).

Create pages from all files in a directory

Thanks for the create plugin!
Is there a way to create pages from all files in _data folders?

For example:

_data/books/
books.yml
Books-2.yml

_data/shops/
-shop.yml
-xyz.yml

Not working with Github pages

Pages are building locally with Jekyll. Not building on Github pages for some reason. This is what my config file looks like:

page_gen-dirs: true # uncomment, if you prefer to generate named folders
page_gen:
  - data: 'contentful.spaces.links.page'
    template: 'page'
    name: 'page_slug'
    dir: ''

If I attempt to bundle gem "github-pages", group: :jekyll_plugins (even locally) the pages no longer build. Any suggestions?

Error in bulding

During jekyll building I have this "jekyll 3.5.1 | Error: undefined method `tr' for nil:NilClass".

Elements ending with a period generate folders instead of pages

Hello.

First, thank you for this wonderful plugin, it allowed me to create a nicely linked web of data on our site (http://mugen.karaokes.moe/en/karas.html)

I have an issue though with some of that data.

When an element ends with a period, like "5pb." instead of creating "5pb..html" it creates a folder called "5pb" and a "html.html" file inside.

See for yourself :

Here's a directory of links : I use the datapage_url liquid tag (I don't think it's mentionned in your README, I found it by looking into the code and it's very useful!)

http://mugen.karaokes.moe/en/creators.html
Try to click on 5pb. there, it redirects to a 404. The URL there seems good to me, the page generated at runtime does not :

Here's the link to the page Jekyll created :
http://mugen.karaokes.moe/en/tags/creator/5pb/html.html

Do you think this is easily fixable?

Thanks in advance

Showing related items on data page

Firstly, thank you for making this plugin! It is extremely useful.

I am wondering if it is possible to use the HTML template for the page to be able to pull in links to 3 other related pages from the same data file?
Within my .yml file I have a category attribute, so I was hoping to use the category of the current page to pull in 'You may also like...' suggestions for other pages with the same category.

BROKEN LINKS

Hi! My links is not routing to the auto-generated page.
I follow and use your code to verify but the links is still not working.

Works with jekyll_get plugin.

Just some feed back.

I have this working with the jekyll_get plugin, which gets data from an external source.

In my setup I am pulling in a JSON file from my Next Cloud server, but it could be data generated from a spreadsheet or database. The data is now available to be used by the jekyll-datapage-gen plugin.

Works really well.

Cannot generate from more than 2 sources

My site requires me to work from a number of YML data sources. I found your plugin incredibly useful for creating a staff directory, so I planned to extend it to some other pages where it would be useful to just generate them off the data source.

When I added a second it worked perfectly, but when I added a 3rd, they all broke.

Any guidance on this issue would be massively appreciated.

Example code:

page_gen:
  - data: 'contacts'
    template: 'profile'
    name: 'name'
    dir: 'field-support/contacts/'

page_gen:
  - data: 'cbt'
    template: 'profile'
    name: 'title'
    dir: 'CBT/'

page_gen:
  - data: 'platform-reference'
    template: 'profile'
    name: 'title'
    dir: 'platform-reference/'

2 of these will work, in any order. But 3 will not.

Filter nested values

I'm attempting to filter based on a category however my category slug is nested under category within my yaml data.

This line does not seem to work:
filter_condition: "record['category.slug'] == 'breaking-news'"

Can't get this to work. Getting 'no implicit conversion of String into Integer'

When I try to compile I'm getting this error:
jekyll 3.1.3 | Error: no implicit conversion of String into Integer

My config file looks like this:

page_gen:
  - data: 'blog_posts'
    template: 'post2'
    name: 'records.fields.title'
    dir: 'blog'

And my blog_posts.json file looks like this:

{"records":[{"id":"reccE5YJmL6JB5RbI","fields":{"title":"Airtable for a website?  Why you'll love it.","content":"Recently, at Sitesfor.church, we made the decision to use [Airtable](http://airtable.com) as the backbone of our church websites.  Airtable is an online database app (if Google Sheets and Microsoft Access had a baby it would look like Airtable.)  Using an app like this is a radical move - as far as we know no other web design company is doing - but we think you are going to love it.\n\n\nWhy?  We thought of ten reasons why you'll like it.\n\n## 1. You own your data.\n\nYour data will live on your Airtable account. You can do whatever you want with it. If in the future you want to use another web service or pay for a custom site - you can still use airtable to update your site. 
(and so on)

What am I doing wrong?

Migrate to Jekyll-Plugin GEM?

adding the plugin contents into _plugins is easy enough but without tests, abstracted class methods, and a .gemspec script, the plugin though handy in conception is in a kind of beta. I've forked this repo for my own purposes - processing data_content in _data files into an API call and on completion realized I'd prefer this as a contained plugin to remove or add easily fromgemand_config`. I think several other issues 'like CSV imports' would be resolved as a result too thanks to a more robust and standard architecture. if nothing else, it's a creative commons so I'll gladly credit this properly but I beieve it's worth considering. . .

oh, and why not `jekyll-page-generator' for a repo/plugin name? 😌

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.