Blog organisation like WordPress

Hello everybody.
I hope this is not duplicated entry. I searched forum and all entries on this topia suggest using tags as categories.

Since im coming from WP world, im used to their structure of blog. Where you have categories as well as subcategories.

My current progress is like this:
In posts.yaml i have structure field with name and slug, and thats where i create categories

And in post.yml i have multiselect field where i choose category…

Problems that i have:

  • no subcategories
  • when some category is deleted, posts under it are still there

Since you can nest structure fields, this would allow you to create subcategories as well. The question is how you can choose them in your posts, because the select or checkboxes fields can only digest a flat structure.

So one way to tackle this would be to to create a flat array of options from the nested structure, where nested items are named `parentCategory-childCategory. I think this is ok as long as the list of options doesn’t get too long.

The alternative would be a custom field that handles nested select elements.

Yes, if a category is deleted, that is not reflected in the text files. There are two ways to deal with this:

  1. Use a hook that goes through all posts and removes the invalid entry (not great if there are many items)
  2. Deal with it on the template side, by checking a given category against the ones stored in your structure field (maybe combine this with checks if a post category is still valid in anpage.update:after hook when a page is updated).
  3. Store the relationships in a lookup-table…

Wordpress stores these relations in an extra table (wp_term_relationships) which makes it easy to remove such relationships. In a flat file environment, you have to be a bit more creative…

1 Like