Wordpress migration - global edits to mobiledoc/JSON or database?

I’m in the process of moving my Wordpress site to Ghost. I have a large number (1000’s) of edits to make to handle some shortcodes that are not supported in Ghost.

Is the most logical way to do this with a regex substitution on the JSON output from the Wordpress site? The regex gets really messy with all the escapes, but looks manageable. For each post it would involve removing the shortcodes and reinserting new HTML at the end of the post.

Alternatively, could I do a ‘local’ import, make edits via some SQL (coupled with some regex magic, easier to read as not escaped) on the sqlite3 database (presumably only the posts table?) and then re-export before importing directly to the final destination?

I’ve got basic but reasonable SQL and perl (yes, a bit old skool, but it works for me) coding so understand the mechanics of what to do, but I don’t know the easiest thing to apply these mechanics to.

With thanks
David

If you’re looking for help, please provide information about your environment. If you delete this template and don’t provide any information, your topic will be automatically closed.

If you aren’t running the latest version of Ghost, the first thing we’ll ask you to do is update to the latest version of Ghost.

  • What’s your URL? This is the easiest way for others to help you
  • What version of Ghost are you using? If it’s not the latest, please update Ghost first before opening your topic

And

  • How was Ghost installed and configured?
  • What Node version, database, OS & browser are you using?
  • What errors or information do you see in the console?
  • What steps could someone else take to reproduce the issue you’re having?

Either approach could work.

Me, I might use Perl to parse the JSON, then run your regexes to fix the data, save the JSON then run the import.

This will make proper escaping less challenging then running regexes directly on the JSON.

Thanks @markstos, since posting the Q I’ve dabbled and determined that using JSON::Tiny on directly the WP Ghost plugin output seems to work well. It looks like there are some oddities in handling elements which are invisible on the WP site but are wrong when imported to Ghost. Of course, these could be WP anomalies ignored on that platform but that are dealt with correctly by Ghost!

Of ~600 posts and a million words of text I’ve got just 12 errors that need to be manually fixed. It’s also a good opportunity to streamline all the tags/categories.

For those wanting to do this it’s the ‘mobiledoc’ output from WP that primarily needs to be edited. Although the html and plain text appear to be imported to Ghost it’s the mobiledoc that is displayed.

Will the Ghost WP export plugin be non-functional when the switch to lexical is completed?

1 Like