-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Description
Breaking out the notes from #1929 so we can discuss the idea with more granularity and (hopefully) track its implementation.
The basic idea is that right now Jekyll recognizes two types of content, posts and pages. Pages can live anywhere, and posts must live in a _posts folder, and must be named a with a specific file format (0000-00-00-title.md). Both posts and pages can have tags, but any tag or category YAML front matter from posts, makes its way into site.tags and site.categories. Essentially, we've got two ways to describe very similar things.
Instead, lets make the basic unit of Jekyll a CollectionObject (or something more creatively named). Think of this as similar to a Node in Drupal or a Post in WordPress. Out of the box, Jekyll will ship with Post and Page Collections initialized, but a user could introduce an infinite number.
CollectionObjects would contain the basic logic (yaml front matter, markdown, permalinks, etc), and could be extended by core collections. Posts for example, would have specific file names, Pages could live anywhere.
To implement a new collection (let's say "Puppies") a user would add the following to their config.yml file:
collections:
- puppiesThis would tell jekyll to look in the _puppies folder (_#{collection_name}) for markdown (or other) files. In that puppies folder, we could have rover.md and spot.md, and they'd be available as site.puppies (as would site.posts and site.pages continue to work). I could then iterate, filter, do whatever. Any file in the _puppies folder will be read in, with or without YAML front matter.
You could also have kittens as _kittens and cars as _cars just as easily:
collections:
- puppies
- kittens
- carsIf you want each puppy rendered (e.g., site.com/puppies/rover.html (or puppies/rover/index.html) you'd add it to a render array:
collections:
- puppies
render:
- puppiesAgain, by default, core collections (pages, posts) are rendered just like before. The idea here is that if a user is using Posts for something other than blog posts, or hacking Pages to be categorized, Jekyll has already failed them. Instead of being categories of pages (or posts), they should be a Collection.
Here are the full, non-prose notes from the meatspace brainstorming session:
Collections
- If people are using blog posts for a non-blog post thing, Jekyll has already failed
- By default, Jekyll registers [posts, pages]
- Can describe additional collections in _config.yml
- Can describe render in
_config.yml, which by default contains pages, posts- Collections rendered, render to
/collection/#{object}- maybe give it a path?- Jekyll looks to “/_#{collection}”
- FIles read in as site.#{collection}
- Collection object basic functionality, extended by posts and pages methods
- Anything in _collections folder is processed as a thing, much like _posts
- Posts, pages extends Collection (Ruby
Object) (or something)- Posts read tags, categories in to site.tags and site.categories, have dates in file names
- Pages don’t live in _collections folder
h/t goes to @parkr for seeding the idea.