Skip to content
This repository was archived by the owner on Jun 25, 2020. It is now read-only.

Wrong handling of categories #247

Closed
thoemmi opened this issue Jun 23, 2015 · 6 comments
Closed

Wrong handling of categories #247

thoemmi opened this issue Jun 23, 2015 · 6 comments

Comments

@thoemmi
Copy link
Contributor

thoemmi commented Jun 23, 2015

In 0fca5ab @laedit implemented that a post's categories come from both the folder and the front matter. Jekyll behanves different, and I think Pretzel's implementation is wrong.

In Jekyll's documentation for variables it says for page.categories

The list of categories to which this post belongs. Categories are derived from the directory structure above the _posts directory. For example, a post at /work/code/_posts/2008-12-24-closures.md would have this field set to ['work', 'code']. These can also be specified in the YAML Front Matter.

This links to the Front Matter documentation, where it states regarding categories:

Instead of placing posts inside of folders, you can specify one or more categories that the post belongs to. When the site is generated the post will act as though it had been set with these categories normally. Categories (plural key) can be specified as a YAML list or a space-separated string.

As far as I understand the docs, categories derive from the directory only if there are no categories specified in the front matter.

@thoemmi thoemmi changed the title Wrong handling if categories Wrong handling of categories Jun 23, 2015
@laedit
Copy link
Member

laedit commented Jun 29, 2015

I'll do some tests with jekyll to confirm that and accept your PR if it's ok.
In any case thanks for your implication and PR! 😃

@laedit
Copy link
Member

laedit commented Aug 11, 2015

Sorry the the long silence treatment, I was out of town for a few weeks.
I just tested it and Jekyll use both directory and front matter categories when they are specified.
I'm gonna close the PR but again thanks for your implication.

@laedit laedit closed this as completed Aug 11, 2015
@thoemmi
Copy link
Contributor Author

thoemmi commented Nov 13, 2015

@laedit I accepted your answer and continued to use my own patched version. However, today I compared again the output of Jekyll and Pretzel.

In fact, Pretzel works like Jekyll when no pagination is used: both use only categories specified in the frontmatter. However, things are different when using pagination. I created a repro at https://github.com/thoemmi/pretzel-categories-test, alls posts are stored in _posts\archive\2015.
Jekyll produces correct categories:
image

But Pretzel adds archive and 2015:
image

When not using pagination, Pretzel is correct. It seems as without pagination it renders post.Bag["categories"], but with pagination post.Categories, and the latter contains the additional archive and 2015.

@laedit
Copy link
Member

laedit commented Nov 14, 2015

Thanks a lot for your implication ! 😃
I have tried to reproduce it but with Portable Jekyll or the last version of jekyll I got this:

jekyll-categories-test

So to me Pretzel have the same functionality than Jekyll about categories.

@laedit
Copy link
Member

laedit commented Nov 14, 2015

But it could be added as a config parameter: only_frontmatter_categories: true for example.

@thoemmi
Copy link
Contributor Author

thoemmi commented Nov 15, 2015

I've used Jekyll 2.5.3 for my tests. After upgrading to 3.0, I see the addtional categories from the path too. I'll create a PR to make it configurable as you suggested.

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

2 participants