Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Why no categories or id for pages? #1168

Closed
anarchodin opened this Issue · 7 comments

5 participants

@anarchodin

I don't quite understand why a few of the variables that are autogenerated for posts are not available for pages as well. In particular, it seems odd not to provide pages with id and categories; both could easily be determined from the filesystem and their availability would make consistent treatment of static and dynamic parts of a Jekyll-generated site easier.

So I'm wondering if there's a conscious design choice behind this difference in treatment, or if it's a historical accident. I would've directed this at the mailing list, except that seems to have had no activity for several months now...

@parkr
Owner

Heyo–

@qrush, @tmm1, and @mojombo might be better suited to discuss the historical events which led to the divergence of these two types of content, but I would hazard a guess that it was a conscious design decision based on existing blogging platforms of the time.

Posts – writings about topics numerous – were given this ability to categorise and tag in order to offer logical groupings of a long list of posts. Pages are meant to be singular and unique. My site may include logical sections of pages (e.g. /docs/), but what is the need or advantage of assigning each page the category docs, as determined by the filesystem?

With regard to your question about why pages don't have ID's, I don't know to what it is you are referring, so you'll have to be a bit more clear on that before I can offer any explanation.

@anarchodin

Specifically, I mean the page.categories and page.id variables that are available to posts but not pages. Both are useful in generating navigation (particularly with the active page or category marked) from filesystem structure rather than explicitly placing navigation metadata into the individual files.

@simonvanderveldt

I want to add to this that when adding categories: foo bar to the front matter of a page the categories do actually appear when using the {{ page.categories }} liquid tag, but since there isn't any processing of the categories inside page.rb it's simply a string instead of the array that categories should be.

This caused me some trouble with filtering {{ page.categories }} because one expects the input to be an array.

I guess the nicest fix would be making categories work for pages as they do for posts as discussed in this issue.

@parkr
Owner

@mattr- I have changed my mind about categorization for pages – I certainly see the value in globbing together certain pages based on a category. A great example is our jekyllrb.com site -- group the docs together and allow us to iterate over them, etc.

Thoughts on #670 as a catch-all?

@cirosantilli

+1. This would be very useful.

#670 would be a good solution, if it also applies to pages in addition to posts.

This was referenced
@parkr
Owner

Categories are for posts – try Collections. That should help solve your problem. They're available on GHP now.

@parkr parkr closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.