Using Drafts with Ghost
Ghost is an open-source CMS/Blogging platform. Drafts supports integration both for creating posts on a Ghost-powered site, and scripting more advanced integrations through the Ghost Admin API.
Authorization
The first time you use any Ghost-integrated actions in Drafts, you will be prompted to provide two pieces of information:
- The URL of your Ghost site. This should be provided as the full URL to the home page of the site, like
https://my-ghost-blog.com/
- Your Ghost “staff access token.” Obtain your token from your profile in Ghost admin. Visit your admin page, select your account at the bottom left, then “Your Profile”.
You will only be prompted once for this information, if you enter it incorrectly, or need to update your token later, you can forget your Ghost credentials in Drafts Settings.
“Ghost” Action Step
The “Ghost” action step provides a simplified method to post to Ghost with a number of common options, the values of which are generated with Drafts’ template tags. Start by installing this example action:
- Post to Ghost: Creates a draft post in Ghost with the first line of the draft as title, and remaining text as content. As configured, the post will be created with “Draft” status.
After install, see action step documentation for details on configurable options. For example, you might with to change the defeat behavior to create posts in published status, or visible only to members.
Scripting Ghost API
In addition to the convenience of the Ghost action step, Drafts provides the Ghost
script object, which provides a wrapper for making requests to any available endpoint in the Ghost Admin API. This allow importing data from Ghost, updating existing posts, and more.
Using the API directly requires an understanding of the API but simplifies access by taking care of authentication, and marshaling JSON request and result data to and from Javascript objects for you.
A couple of example actions demonstrate usage:
- Post to Ghost with Options: A scripted action to create a post that prompts the user to select a variety of options for the post before creating it.
- List Posts from Ghost: Imports recents posts from Ghost, and creates a new draft with a Markdown list of post titles and links.
About Markdown, HTML and Ghost
Ghost stores content in a native structured format, and, of course, publishes at HTML. The integrations in Drafts send content to Ghost as HTML, which is supported by their API. Generally, we recommend writing in Markdown, and the default behavior of the actions above is to convert your Markdown to HTML to upload.
Conclusion
These examples should get you started with basic Ghost integration. Please feel free to ask if you have additional questions.