Does `<!--kg-card-begin: xxx>` syntax work for block types other than HTML?

I’m trying to create a post using the API. I want an option to have the text you send inserted into a Markdown block, because I write in Markdown, and I want Ghost to be as close to that as possible.

I’ve successfully used the method in the docs to send the text as an HTML block:

{"posts":[{"title":"HTML Card Test","html":"<!--kg-card-begin: html-->\n<p>My post content. Work in progress...</p>\n<!--kg-card-end: html-->","status":"published"}]}

However, my attempt to make content in a Markdown card was not as successful.

{"posts":[{"id":"688cbc3781bb8c0001fef143","title":"Test Note","html":"<!--kg-card-begin: markdown-->\n# First Heading\nSome text\n![](http://localhost:3003/content/images/2025/09/UKBall.png)![](http://localhost:3003/content/images/2025/09/Screenshot-2023-10-05-at-7.39.15-pm.png)\n\n![Another note](Another%20note.md)\n\n![External image](https://http.cat/404)\n<!--kg-card-end: markdown-->","status":"draft","updated_at":"2025-09-04T18:28:56.000Z"}]

I found this post which references it, and I found it was used in a few places in the source code, but I can’t get it working for myself. Does it just not work through the admin API?

Ghost doesn’t operate on HTML directly, it uses an internal format based on Lexical. When you import a post from HTML, Ghost deserializes the content to Lexical. The markers in the HTML are used to determine which card was originally used.

The problem with your markdown example is that Ghost is converting HTML back to Markdown, so the behavior seems reasonable.

If you want Ghost to render the markdown, you’ll need to use the Lexical format. Luckily, the Koenig demo can show the JSON output. Here’s a simple example:

{
  "root": {
    "children": [
      {
        "type": "markdown",
        "version": 1,
        "markdown": "# Hello, world!"
      }
    ],
    "direction": null,
    "format": "",
    "indent": 0,
    "type": "root",
    "version": 1
  }
}
1 Like