Skip to content
This repository has been archived by the owner on Nov 29, 2017. It is now read-only.

Collection files don't display without YAML front matter #223

Closed
maban opened this issue Jan 2, 2015 · 12 comments
Closed

Collection files don't display without YAML front matter #223

maban opened this issue Jan 2, 2015 · 12 comments

Comments

@maban
Copy link

maban commented Jan 2, 2015

I've been playing with collections since they first came out and I built this with it: http://style.maban.co.uk/ (code here: https://github.com/maban/styleguide) – each item on the page is pulled from a collection which is a series of pure HTML files that don't contain any front matter, and I generated it like this:

{% for pattern in site.patterns %}
    {{ pattern.content }}
{% endfor %}

and in my config file I've got

collections:
    patterns:
        output: true

It was working great until recently, and I hadn't touched the code until someone said it wasn't working for them and I tried it out again locally. Now when I build the site, none of the files in the collection get generated on the page. The only way they'll display at all is if I insert an empty front matter to each file in the collection.

In the documentation for the content variable of collections, it says "If no YAML Front Matter is provided, this is the entirety of the file contents.", so it should still work, right?

Has something changed in the codebase that basically says "don't output this collection file if it's not got front matter"? Or am I doing something wrong – is there a way to force it to generate it anyway?

maban added a commit to maban/styleguide that referenced this issue Jan 3, 2015
The only way to get the patterns generated by Jekyll was to add empty
front matter to each file. I don’t think this is right, so I’ve raised
a ticket with Jekyll: jekyll/jekyll-help#223
@troyswanson
Copy link
Member

As far as I know, Jekyll will only process a file through it's generator system if it contains front-matter. I honestly don't know the history of that behavior, but I feel like it's been like that since Collections was introduced. Obviously there could be nuiances that I'm not aware of, but the idea is generally: "Add front-matter to files that you want Jekyll to process."

@maban
Copy link
Author

maban commented Jan 5, 2015

It did used to work. If that's how it is now, would it be worth changing the wording of the documentation? This had me thinking it would process a file without front-matter:

Create a corresponding folder (e.g. /_my_collection) and add documents. YAML Front Matter is read in as data if it exists, if not, then everything is just stuck in the Document’s content attribute.
http://jekyllrb.com/docs/collections/#step-2-add-your-content

@nternetinspired
Copy link

@maban That's a very inspirational use of Jekyll, I love it!

🙇

@maban
Copy link
Author

maban commented Jan 5, 2015

Thank you, @nternetinspired! I'm also building a jekyll-based collaborative bookmarking tool. Here are my very early workings: https://github.com/maban/bookmarks

@nternetinspired
Copy link

Looks great @maban, I'll certainly keep an eye on that. I'm really interested in how Jekyll can be used in new ways, like cutting production time of the less glamorous, but essential, parts of the web design process; and I think style guides are a really important part of that.

I've been dabbling with using Jekyll to replace traditional web design tools in rapidly creating things like element collages, style tiles, and type samples in addition to just wireframing: https://github.com/nternetinspired/jekyll-design

A fully fleshed out pattern library is next on my hit list…

@maban
Copy link
Author

maban commented Jan 5, 2015

Oooh, looks really cool!

@paulrobertlloyd
Copy link

Hey @nternetinspired, your project looks fantastic! I love what people are doing with Jekyll… next on my list is Jekyll-ising my Barebones project (https://github.com/paulrobertlloyd/barebones).

@nternetinspired
Copy link

Thanks for the kind words @paulrobertlloyd 😊

I really need to give it some more time and refine things a bit further because I'm happy with how it works as a POC. I'll be keeping an eye on Barebones for inspiration ;)

@pmackay
Copy link

pmackay commented Jan 8, 2015

I'd agree here that the docs need a fix, or the behaviour needs changing so files without front matter are processed.

@maban
Copy link
Author

maban commented Jan 8, 2015

Oh, the docs are on GitHub! I'll try and write something that might help clarify things, and do a pull request after work.

@ldionne
Copy link

ldionne commented Mar 23, 2016

Actually, it would be very useful if files without a front matter could be processed too. My use case is that my collection contains HTML files representing charts of C++ benchmarks. These benchmarks are updated nightly by a CI script, and they should also be viewable as-is. Hence, generating the files with a front matter is not an option.

Right now, the only thing I can do is add a dummy front-matter to those files so that they are processed, but it's not ideal.

@mcdemarco
Copy link

Files without frontmatter were definitely supported in the past. I added a collection of markdown-formatted recipes with no frontmatter to my site in October 2014 and have had it there ever since. I copy the collection from another repository where the frontmatter would be in the way.

To get my collection building again after an accidental upgrade of Jekyll, I had to downgrade to Jekyll 2.1.1. To do this, run:

gem uninstall jekyll
gem install jekyll -v 2.1.1

Before I downgraded, I confirmed the bug by adding frontmatter (just a title) manually to one file, which then generated. I wasn't able to test older versions than 2.1.x because the gems would no longer build for me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants