Matt's Dev Log

dataMigration

To import posts into WriteFreely from an outside platform, it is ideal to get all articles into a JSON document that looks like the following, where each object in the array is a complete article:

[
  {
    "title": "Optional Post Title",
    "slug": "optional-post-title",
    "body": "Entire post content, in Markdown or HTML, including any images and #hashtags.\n\nNote: newlines should be preserved in this field, even when using HTML.",
    "font": "serif",
    "lang": "en",
    "rtl": false,
    "created": "2006-01-02T15:04:05Z"
  }
]

These field names map directly to the API — you can read details in the API documentation. Otherwise, a few notes:

  • The slug should contain only alphanumerics and hypens. Any invalid characters will be automatically converted.

  • The body property should include all original markup (HTML) and Markdown, with newlines (WriteFreely respects and requires newline literals). Note: Getting as close to Markdown / plain text as possible here is ideal, as it provides the best editing and data export experience. But WF will render HTML.

  • Include any categories or tags as #hashtags, inline in the body. To make it look nice, you might append any to the end of the post, separated from the post body by \n\n.

  • Supply a created time, in the RFC3339 format (shown above) and converted to the UTC timezone, to preserve original publish date and time.

In this format, we can trivially loop through the array of objects and POST each one directly to the WriteFreely API — creating either drafts or blog posts.

#WriteFreely #import #dataMigration


Get future updates via RSS and ActivityPub: @devlog@matt.writefreely.dev.