Optimizing Content Prepend using Ghost Admin API

I’m currently posting programmatic updates to a page that already contains existing content I do not want to lose. Specifically, I am prepending HTML content to a page that already has content using the Ghost Admin API.

My current approach involves fetching the existing content, storing it, and then reposting the old content along with the new content. However, I’m curious if someone might know of a more efficient method to achieve this where I can simply add the new content.

I currently have a function calledupdateGhostBlog This is where the HTML prepending takes place. The function first fetches the existing HTML content of a specified page (identified by TARGET_PAGE_ID ) using the Ghost Admin API. It stores this content in a variable (existingHtml ). Depending on the action (created , updated , etc.), it either prepends the new HTML content to this existing content or handles it differently. In this case, for the ‘created’ action, it prepends the new HTML (htmlContent ) to the existing content. The combined HTML is then used to update the page on the Ghost site through the Admin API.

Is there a more efficient way to prepend new data to a page without first retrieving the existing content? Since I’m doing this in a cloud function I don’t want to run up against time/data limits if the page gets too large.


Every post save needs to include the full content. That’s exactly what the editor itself does on every save, there’s very little optimisation to be gained from trying to prepend only the changes compared to the complexity involved in supporting that.

1 Like

I sorta figured which is why I did it that way. Thanks for confirming!

My issue is more that functions have a limit of time / memory they can run within. Hopefully, it will be a LONG time before this page exceeds that as it’s small fragments of HTML.

tldr I am posting bookmarks I added to omnivore (which contain an annotation and a ghost tag) to a linkroll page which is a handy way to “blog” even when I am having a lazy day.