-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support multiple non-hierarchical categories #848
Comments
现在Hexo应该不支持多级目录吧? |
支持多级目录,但是不支持一篇文章多个同级目录,比如: - HTML
- CSS 就会生成 |
This is a feature request for a post having multiple categories. |
@leesei the difference between |
@Xuanwo Categories can be both hierarchical and non-hierarchical. Tags are not hierarchical. I was tagging it as a feature request. Not committing to add this feature to Hexo. |
@leesei How about rename it as |
@leesei I take some time to think this feature request. |
For people coming from WordPress this can cause a bit of a headache, since the WP migrator tries mapping back the multi-category selection present in WP to something, creating a completely new and unintentional category structure. An example: In WP, there are three posts: one in the Personal category, one in the Travel category and the other one in both the Personal and Travel categories. (Those are same level categories.) As the result of the migration, you would end up with the following category structure:
Note the difference between Personal > Travel and Travel; the post originally with both categories is not going to be available under Travel. I'm not saying that any way (WP vs. Hexo) is better than the other, but this can be definitely confusing. If someone just wants to convert his existing site to Hexo like I do, one might need to rework all blog posts to clean up the category structure. (I'm also aware that this might be the WordPress migrator's responsibility to handle.) |
I just got caught by this myself. It took me a little while to figure out that I hadn't done anything wrong. How I expected it to work would be:
produces::
Hierarchical categories should have been indented in my opinion. Categories with the same level of indentation should be at the same level. |
I'm hoping to dig into this one at some point in the next month. It should be possible to provide a setting in the categories:
- Category 3
- Subcategory 3.1 (I'm not sure if that's valid YAML, but I'll find out soon.) If anyone wants to point me to a spot in the code where this determination would be made, feel free. :) |
There is some progress here. I still need to clean it up, write some more tests, verify generators pick up the new categories, update docs, etc., but I'm excited. The way it currently works is that, if the post defines categories the current way, they will be rendered the current way. i.e., categories:
- this
- is
- cool would end up with the category categories:
- [ some, cool ]
- way ...it will end up with two categories - This way preserves the default, but allows the flexibility for defining different hierarchies without changing the front matter too much. It would impact importers, if (for example) they want to import from WordPress and preserve its category hierarchy. Feel free to provide feedback on this approach; simple is good, but unintended side effects are not. |
Now the feature supported by @danieljsummers . Close the issue. |
I agree with this idea by @Xuanwo
Category should be a tree like this, not tag. Tag is better for non-hierarchical annotation. |
No description provided.
The text was updated successfully, but these errors were encountered: