Converting WordPress blog posts to Kirby

Hi,

I’m working on a new Kirby website that will replace a WordPress website (200 blog posts) and I’m running into problems using markdown to convert the posts.

I’m a newbie to Kirby, so I’m working with the StarterKit, which I downloaded today using Herd (Kirby 5.0.4).

I modified a node script ( GitHub - lonekorean/wordpress-export-to-markdown: Converts a WordPress export XML file into Markdown files. ) to take the XML export of WordPress posts and convert the posts to markdown files saved in the Kirby file structure. All looks good structurally—each post appears in its own folder as notes.txt and the appropriate images are in the correct folder too.

In the panel and in a browser, the meta data—title, date, and tags—were being read properly, but the markdown in the body was not getting parsed correctly. (If I manually copy the body text into a markdown block in the panel, the content looks fine, so I’m reasonably sure that the issue is not my conversion from XML to markdown.)

On this forum, I found a thread with a similar markdown problem in Kirby v2 where the solution was to add →kt in the template. In note.php on my local install, I replaced

<?= $page->text()->toBlocks() ?>

with

<?= $page->text()->kt() ?>

I also edited config.php to include

'markdown' => [
	'extra' => true
]

This is an improvement! When I copy a markdown-formated note to my Herd website and look at it in a browser, the markdown is properly parsed and the page appears as expected with links, italics, boldface, headings, etc.

But this is not a solution. When I look at that same note in the panel, the markdown in the body is not parsed. If I edit anything–for example, correct a typo or add a new block–and save the note, the markdown parsing fails. In a browser, the edited note now appears with [{“content”:{“text”;" at the beginning of the body, then the body with unparsed markdown, and "},“id”:“0c73e192-e628-4819-9a73-f60f6e499967”,“isHidden”:false,“type”:“text”}] at the end.

For day-to-day editing, my client will use kirbytext and blocks in the panel. I thought using markdown files would be the easiest way to convert the WP posts to Kirby notes, but that may not be the case.

What am I missing? Is there a setting I need to change? Is there a better way than markdown to convert blog posts from WordPress to Kirby?

If you use a field of type block and store markdown in it, it will not work properly.

You either need to store the markdown in a textarea field, or all in block of type markdown, or you need to convert the markdown to different block types as required.