Adding Category to Posts - Running a Migration

Hi,

I am trying to explore Ghost from the perspective of building a website on top of it. I found a pretty helpful documentation and was encouraged to play a bit with the source code and do some experimentation.

As a first of trying to understand Ghost source code, I was trying to add a String field (category) to the Post object, and build an end to end flow to add, edit (in the admin editor) and show the category (in the editor and front end UI).

I wanted to seek help to understand how I may go about adding a new field to the Post object / table. I referred to the following posts:

  1. Database Migrations by @Hannah
  2. Adding a property to the post context object

[1] was very helpful - However, it appears a little bit dated with respect to the current code base I think - since some of the files I couldn’t find.

I would be grateful If anyone could help with the following two questions:

  1. How to add a String property to a Model?
  2. How to run migrations?

Regards,
Sidd

1 Like

I’m no developer (so I might be saying smth stupid), but wouldn’t it be easier to just use the existing tag system and rewrite the URL’s to behave like categories (i.e. so that you have domain.com/tag-name/ rather than domain.com/tag/tag-name/?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.