Import skipping post body


#1

EDIT: This is still an issue for people without pro, and I don’t appreciate you closing the thread on me.

Ghost Pro is importing all my posts but skips the “html” attribute so my posts have no bodies.

  • What’s your URL? This is the easiest way for others to debug your issue Not relevant
  • What version of Ghost are you using? Pro
  • What configuration? pro
  • What browser? what
  • What errors or information do you see in the console? don’t think it’s relevant but
    [Error] Viewport argument key “minimal-ui” not recognized and ignored. (ghost, line 15)
    [Error] SyntaxError: Unexpected token ‘<’
    (anonymous function)
    [Error] SyntaxError: Unexpected token ‘<’
    (anonymous function) (signin:1)
  • What steps could someone else take to reproduce the issue you’re having? try importing this https://gist.github.com/jtth/abe9b75662a64ae6001959f7d630f211

#2

Hi there! If you’re having any issue with a Ghost(Pro) site, please drop us an email on support@ghost.org and we’ll be more than happy to give you a hand directly :slight_smile:


#4

Hey @jtth :wave: Which version of Ghost has this backup been created on (Pro or self hosted)? It’s missing mobiledoc fields in it and that’s the reason why html fields are now being saved (html is generated from mobiledoc)

Edit. Sorry, while looking into the data totally forgot you have given the answer to the question :sweat_smile: I’ll ping somebody on the pro team about this issue.


#5

#6

Hi @jtth :wave:

The reason the post content isn’t importing is that the html field in Ghost is a generated value, with the contents being generated from the mobiledoc field. Your import file doesn’t contain any mobiledoc fields for each post, thus the reason they are appearing “empty”.

You can view a full example of a post import here for reference.


#7

There’s no mobiledoc structure in that example, though. Do you have an example of that?


#8

Details in the context of the post resource: https://api.ghost.org/docs/post#section-mobiledoc
Full mobiledoc spec: https://github.com/bustle/mobiledoc-kit/blob/master/MOBILEDOC.md

Available cards in Ghost: markdown, html, code, image, gallery, embed, and hr. The best resource right now to see the expected payloads for those would be the source code.


#9

Y’all make it kinda hard to love you.

Here’s a working importer.

(Why do you escape the mobiledoc structure? So odd.)


#10

:laughing: I think we’re all hard to love around here @jtth

You might consider opening a PR back to: https://github.com/mattvh/Jekyll-to-Ghost which is not maintained or developed by the Ghost team.

I’m guessing it fit Matt Harzewski’s (I don’t know him but his Github had his name on) needs at the time but looks a little unloved and it’s inclusion in the docs might need reviewing.

With regards to the escaping of the JSON in the JSON… although mobiledoc itself is JSON, the field it is stored in is a string rather than a JSON object so the JSON needs escaping. Probably because it’s more performant to encode a JSON object to a string for storage (in the DB) or decode a string to JSON than it is to parse JSON into different DB columns or records.

Before it gets said: sure there’s mongo, cassandra, couchbase… and many other fine document stores, even JSON types in MySQL and PostgreSQL that could be used but that adds extra technology dependencies or version restrictions (MySQL 5.7 / 8 +) to users for very little overall benefit.

This has been an interesting forum thread. Nice work getting the Jekyll importer functioning, I hope it helps others who encounter this problem or want to migrate Jekyll to Ghost :slight_smile:


#11

I hope it’s useful to someone else too. It’s not perfect, but the Jekyll to Ghost conversion seems like a thing people flirt with, at least, like I am.

(And I did open a PR. I adapted my version from an already-pending PR; that repo seems abandoned.)