Categories in the path are ignored #2633
Conversation
… attribute was not set
What are we missing? This shouldn't be necessary. Line 55 in d2aa8dc |
Not so sure because regarding the def initialize(site, source, dir, name)
@site = site
@dir = dir
@base = self.containing_dir(source, dir)
@name = name
p name
p dir
self.categories = dir.downcase.split('/').reject { |x| x.empty? }
self.process(name)
|
I think the way to have categories in your path is something like this: This PR will allow for the second url to work which I think is more intuitive than the first one. |
@@ -159,6 +159,8 @@ def <=>(other) | |||
# Returns nothing. | |||
def process(name) | |||
m, cats, date, slug, ext = *name.match(MATCHER) | |||
self.categories ||= [] | |||
self.categories += (cats || '').split('/') |
parkr
Jul 26, 2014
Member
We should probably .map(&:downcase)
We should probably .map(&:downcase)
This change broke all my permalinks. I used subfolders in _posts to sort a large volume of posts arbitrarily. Now all of a sudden my posts have different URLs. |
Actually it wasn't an easy change because changing from |
As far as I can tell this change decreases functionality. I used to be able to have categories like this: Create
(in addition to just putting the category in the front-matter) I used to be able to sort sort posts in that Now I literally can't do that and it sucks. And since the permalinks option does not seem to be working right, I can't fix this through a configuration option. This feature of treating A) Optional as it breaks existing sites, makes it impossible to sort post files inside of |
Because you're seeing categories in your URL's now? This PR fixed a bug (if you look at the code, it was meant to use those subfolders inside We can't make these optional. My only thought is to either turn on or turn off all folder categories. The front matter I'm sorry this broke your site, but you were exploiting a bug in Jekyll, not a feature. |
@parkr What you are calling a bug has been a functionality of of Jekyll that I have used since August 2013, and I don't remember when this wasn't the case. So far I am able to test this functionality back to We already have the ability to assign categories all posts in specific If anything this, at least externally, appears as a design decision (rather than a bug) which leaves me with a few questions/comments: a) When did this "bug" appear?
This strays from that behavior in a pretty big way. What does @mojombo think of the change? Ignoring edge cases, the genius of the category folder above the e) Before we had sortable post files that had no effect on post category. Now we don't and any regeneration on gh-pages where this update is mandatory and often unexpected unless you stay up on Jekyll news, breaks permalinks which is a faux pas as we can all agree. For sites that have lots of posts, this really sucks. If this was truly a bug, then it was certainly a useful one. Would you prefer I open a separate issue discussing the use of |
I just noticed that the current documentation notes the extent of categories assigned to posts by directory pretty clearly here:
Note, it says nothing about the use of subdirectories. I would like to propose a revert of these changes until we can find a way assign subfolder information to posts in a way that is less disruptive and preferably optional or at least more flexible. |
You're totally right. Can you whip up a PR to reverse this? Please leave the unit tests, but modify them so they expect no categories where we don't expect them. I'll add it to the 2.2.1 release. We should have caught this with failing tests somewhere, but it seems we didn't add this as a test case before. The docs you mention were written by TPW back before the 1.0 release: 17bb13a |
Sure. I can start that. I will start a new issue to discuss how attributing metadata to posts from I'm going to rack my brain and jekyll sites for random 'tricks' that may be under documented so that we can nail these things down and get them documented better. Also Apologies for the walls of text and excitement and thank you for all the other awesome changes in Jekyll lately! Your doing great work :) Also noticed the acknowledgment of
|
What is the state of this issue. Will support for subdirectories be added later? |
No. See #2705. The subdirectories are read but the categories will not be consumed. This is a historical, somewhat by-accident feature and will not be changed. |
@bodokaiser @parkr were you open to a PR allowing for sub dirs to assign meta data to posts as long is it didn't break the current behavior? |
@bcomnes, and others who find this a little unclear: This folder structure creates a category:
This does not create a category, and it does not change the permalink:
|
@bcomnes Did you find a way to use subdirs as categories without breaking existing behavior? I would like to have quite a few categories. But there are also other top-level folders, for example holding statically hosted files. So it becomes confusing which directories is are categories and which are not. |
No, not really but it has been a while since I tried
|
When using subdirs to reflect categories, the underlying
categories
attribute was not set. I've added a new unit test and updated some others.