I’ve setup ghost to be a headless cms, but I some questions regarding the data:
Can you add custom fields or post/page data either through the admin API or the admin interface somewhere?
Can i only see and modify the points of data available in the template?
It seem pretty limiting to only allow what’s in the template considering the headless route ghost is headed, but maybe I’m missing something.
Hi @austinthetaco, what kind of custom field are you trying to add? You might be able to utilise existing options within Ghost
Hi @DavidDarnes Maybe it would make more sense for me to tell what i’m trying to accomplish: i’m trying to create a catch-all site for my content. part dev blog, part dev portfolio, and part photography portfolio. I’d really like a way to flag posts as different types so that i could render each category on a separate page (i.e. a “my photos” page that contains a series of posts, each post containing multiple pictures).
Ah I see. In that case you probably want to look into custom collections that let you filter items into different collections, like portfolio or photography:
That probably works well enough on handlebars, unfortunately I’m using gatsby. Are you suggesting the main way to have my pages is to just filter on tags? That unfortunately doesn’t let me generate new collections in the ghost admin that will generate a new collection page without locking up my ability to use primary tags for other purposes.
If you’re only going to be creating a couple of new collections then you won’t need that functionality in the admin surely?
I could bump this with another use case: I’d like to attach custom fields that I can query in the API in order to provide deeper customization and functionality to my self-rendered blog posts. One quick example:
On this page: Brian Lovin I am using a photo from a great illustrator on Dribbble. I’d love to be able to add custom data to my post that is like:
That way I could remove the attribution from my post body as a block quote entirely, and render my photo attribution in a more unique way (e.g. overlaying the link on top of the photo itself).
I would imagine that this could be a series of custom key/value input fields that get appended to an
extraData field or something on the post API response. What do you think?
I’ve been on vacation which is why I wasn’t able to respond. Thanks for providing a detailed use case. The feature you’re describing sounds more like a feature for adding captions to feature images, which is being proposed here: Image Caption for Feature Image. I’ve quoted your use case as I think it provides further support for the feature.
While it isn’t an ideal solution, you could utilise the existing image caption feature within body content images. If you placed the feature image into the post content as the very first item, and adjusted the markup so the post heading is at the same nesting level as the post content, you could reorder that image to come before the heading and style the caption to go over the image as well.
I’ve created an example on CodePen:
I realise this isn’t perfect (I too would like the ability to add captions to feature images) but this at least makes the editing experience a bit more sensical
I have created an app to solve this problem. With Gaspr.io you create custom fields, create a template to display fields and add template to your post with a one line of HTML card.
Let me know if you need some help setting it up
I am using Ghost CMS in headless mode. I have a use case where while writing one blog we can specify other relevant blog post. So having custom fields would be very useful as then I can take those custom fields and render relevant link to those posts at the end of page.
Same use case here, we’d like to use our own code to find related posts to be recommended at the bottom of a post, and a custom field would be perfect for this. We could rely on internal tags, but it feels hacky, and would create many of them.