{"id":4129,"date":"2019-10-26T09:28:28","date_gmt":"2019-10-26T14:28:28","guid":{"rendered":"https:\/\/www.threshold-zero.com\/cblog\/?p=4129"},"modified":"2020-09-13T15:09:28","modified_gmt":"2020-09-13T20:09:28","slug":"converting-ghost-cms-output-to-csv-for-wordpress-import","status":"publish","type":"post","link":"https:\/\/www.threshold-zero.com\/cblog\/2019\/10\/converting-ghost-cms-output-to-csv-for-wordpress-import\/","title":{"rendered":"Converting ghost cms output to csv for wordpress import"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>If you&#8217;re just coming here for the solution, and don&#8217;t want to read the backstory about how I came up with the solution, I understand. :)  <br><br><a href=\"#the-solution\">Click here<\/a> to skip to the solution.<\/p><\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">The Problem<\/h2>\n\n\n\n<p class=\"has-text-align-left\">Recently I helped convert someone&#8217;s main blog from Ghost, back to WordPress.  <br><br>While WordPress makes it easy to <em>export<\/em> in any format (so that you can easily import your entries into another blog engine), Ghost&#8230; does not.  <br><br>While Ghost certainly does have an &#8220;export&#8221; tool, it exports in JSON format.  JSON format is definitely preferable to XML, but no matter what, I could not find a way to import these entries into WordPress.<\/p>\n\n\n\n<p>I searched through the plugin library&#8211;nothing was devoted to allowing an import through Ghost.<\/p>\n\n\n\n<p>I furiously Googled&#8211;weirdly enough, any entries I could find about converting Ghost&#8217;s output to something that WordPress could import were all <em>years<\/em> old (and thus none of the solutions presented worked anymore, because I imagine Ghost&#8217;s export format had slightly changed.)<\/p>\n\n\n\n<p>So, I decided to make my own.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a id=\"the-solution\">The Solution<\/a><\/h2>\n\n\n\n<p>The solution is on Gitlab &#8212; just <a href=\"https:\/\/gitlab.com\/M-D-M\/ghost-to-wordpress-data-conversion\">download the Powershell script<\/a> (the .ps1 file) and run it on the command-line, passing one parameter of &#8220;jsonFile&#8221;, which is the path to the Ghost export.<\/p>\n\n\n\n<p>Then, you&#8217;ll need a plugin to import the new CSV file to WordPress &#8212; I used the &#8220;WP All-Import&#8221; plugin.  It seemed to be well maintained, and unlike many other plugins, it didn&#8217;t require you to pay for it.<\/p>\n\n\n\n<p>That&#8217;s it!  I built it in Powershell, because A) I can make quick scripts very quickly in Powershell, and I was frustrated by this point, B) Powershell has <em>very<\/em> good native CSV and file format conversion abilities, and C) Powershell can now run on any platform (Linux and MacOS included).  <\/p>\n\n\n\n<p>If you&#8217;re running this script on Windows, you already have Powershell installed, but if you&#8217;re running it on any other system, the link to install Powershell will also be below.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Future Enhancements<\/h2>\n\n\n\n<p>I only had posts with single tags to test against, so my script is only designed to get one tag for each post for the new CSV-formatted entries.<\/p>\n\n\n\n<p>Ghost&#8217;s JSON format for tags was&#8230; bad.  I don&#8217;t know why it was the way that it was.  With every other type of metadata you&#8217;d need associated with a post, their JSON has that data in the &#8220;post&#8221; object, but with tags, they&#8217;re in a completely different other place, and only associated to posts through a series of IDs.  It&#8217;s weird.<\/p>\n\n\n\n<p>Either way, if you come up with a solution to that, feel free to fork the project!  (Or just suggest a pull request.)<\/p>\n\n\n\n<p>Also, I&#8217;d like to eventually re-code this into Python, just because more computers probably use it by now!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Sources<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Ghost to WordPress Exporter: <a href=\"https:\/\/gitlab.com\/M-D-M\/ghost-to-wordpress-data-conversion\">https:\/\/gitlab.com\/M-D-M\/ghost-to-wordpress-data-conversion<\/a><\/li><li>WP All-Import Plugin:  <a href=\"https:\/\/wordpress.org\/plugins\/wp-all-import\/\">https:\/\/wordpress.org\/plugins\/wp-all-import\/<\/a> <\/li><li>Powershell Installation: <a href=\"https:\/\/github.com\/PowerShell\/PowerShell\">https:\/\/github.com\/PowerShell\/PowerShell<\/a><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;re just coming here for the solution, and don&#8217;t want to read the backstory about how I came up with the solution, I understand. :) Click here to skip to the solution. The Problem Recently I helped convert someone&#8217;s main blog from Ghost, back to WordPress. While WordPress makes it easy to export in [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[18,15],"tags":[],"class_list":["post-4129","post","type-post","status-publish","format-standard","hentry","category-programming","category-science-and-technology"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2ZUZG-14B","_links":{"self":[{"href":"https:\/\/www.threshold-zero.com\/cblog\/wp-json\/wp\/v2\/posts\/4129","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.threshold-zero.com\/cblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.threshold-zero.com\/cblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.threshold-zero.com\/cblog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.threshold-zero.com\/cblog\/wp-json\/wp\/v2\/comments?post=4129"}],"version-history":[{"count":6,"href":"https:\/\/www.threshold-zero.com\/cblog\/wp-json\/wp\/v2\/posts\/4129\/revisions"}],"predecessor-version":[{"id":5502,"href":"https:\/\/www.threshold-zero.com\/cblog\/wp-json\/wp\/v2\/posts\/4129\/revisions\/5502"}],"wp:attachment":[{"href":"https:\/\/www.threshold-zero.com\/cblog\/wp-json\/wp\/v2\/media?parent=4129"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.threshold-zero.com\/cblog\/wp-json\/wp\/v2\/categories?post=4129"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.threshold-zero.com\/cblog\/wp-json\/wp\/v2\/tags?post=4129"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}