Skip to content
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

Closed
diaocow opened this issue Sep 19, 2014 · 15 comments
Closed

Support multiple non-hierarchical categories #848

diaocow opened this issue Sep 19, 2014 · 15 comments

Comments

@diaocow
Copy link

diaocow commented Sep 19, 2014

No description provided.

@Xuanwo
Copy link
Contributor

Xuanwo commented Sep 22, 2014

现在Hexo应该不支持多级目录吧?

@Alex1990
Copy link

支持多级目录,但是不支持一篇文章多个同级目录,比如:

- HTML
- CSS

就会生成 HTML>CSS 结构的目录,HTML变成了CSS的父级目录,而我原先使用WordPress写的文章很多文章使用了两个目录,结果我从WordPress导入的文章目录列表结果很乱。不知道怎么才能修正好,迟迟没有迁移呢。

@Xuanwo
Copy link
Contributor

Xuanwo commented Apr 11, 2015

@Alex1990 这种需求,还是推荐使用Tags。

@diaocow 正如楼上所说,多级目录可以通过

- HTML
- CSS

实现。

@leesei
Copy link
Member

leesei commented Jul 16, 2015

This is a feature request for a post having multiple categories.

@Xuanwo
Copy link
Contributor

Xuanwo commented Dec 1, 2015

@leesei the difference between categories and tags ?
I don't support the idea to add this featur, one way do one thing.
How about your idea?

@leesei
Copy link
Member

leesei commented Dec 2, 2015

@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.
Maybe we could rename the label 😉 .

@Xuanwo
Copy link
Contributor

Xuanwo commented Dec 3, 2015

@leesei How about rename it as feature request ?

@Xuanwo
Copy link
Contributor

Xuanwo commented Dec 6, 2015

@leesei I take some time to think this feature request.
Now I support to add multilevel categories whitout same level categories. And I think this way can give categories and tags different meanings and work together well.

@leesei leesei changed the title 【咨询】在新建一个文件时,如果设置categories属性,才能支持多级目录 Support multiple non-hierarchical categories Mar 1, 2016
@scorchio
Copy link

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:

  • Personal
  • Personal > Travel
  • Travel

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.)

@yannduran
Copy link

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:

  • Category 1
  • Category 2
  • Category 3
    • Subcategory 3.1

produces::

  • Category 1
  • Category 2
  • Category 3 > Subcategory 3.1

Hierarchical categories should have been indented in my opinion. Categories with the same level of indentation should be at the same level.

@NoahDragon NoahDragon mentioned this issue Apr 6, 2017
53 tasks
@danieljsummers
Copy link
Contributor

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 _config.yml file (maybe flat_categories: true, where false is the default). Ideally, then you could specify a category structure in your post...

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. :)

@danieljsummers
Copy link
Contributor

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 this/is/cool. However, if any of the categories are a list themselves, it will create multiple categories. So, if it looks like...

categories:
- [ some, cool ]
- way

...it will end up with two categories - some/cool and way.

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.

@NoahDragon
Copy link
Member

Now the feature supported by @danieljsummers . Close the issue.

@xu-song
Copy link
Contributor

xu-song commented Mar 31, 2018

I agree with this idea by @Xuanwo

the difference between categories and tags ?
I don't support the idea to add this featur, one way do one thing.

Category should be a tree like this, not tag.

Tag is better for non-hierarchical annotation.

@puguojingm
Copy link

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

No branches or pull requests

10 participants