@abeedoo/ghost-cli
v1.0.1
Published
Minimal CLI for managing Ghost CMS posts, pages, and tags
Readme
@abeedoo/ghost-cli
Minimal CLI for managing Ghost CMS posts, pages, and tags. Zero dependencies.
Install
npm install -g @abeedoo/ghost-cliOr use with npx:
npx @abeedoo/ghost-cli list postsSetup
Get your Admin API key from Ghost Admin → Settings → Integrations → Add custom integration.
Configure credentials using any of these methods (checked in priority order):
1. Environment variables
export GHOST_URL=https://your-ghost-site.com
export GHOST_ADMIN_API_KEY=your-id:your-secret2. --env flag
ghost-cli --env /path/to/config list posts3. .ghost-cli file (recommended)
Create a .ghost-cli file in your project root:
GHOST_URL=https://your-ghost-site.com
GHOST_ADMIN_API_KEY=your-id:your-secretAdd .ghost-cli to your .gitignore — it contains secrets.
4. .env file
Falls back to .env if no .ghost-cli file is found:
GHOST_URL=https://your-ghost-site.com
GHOST_ADMIN_API_KEY=your-id:your-secretMulti-site config
Your .ghost-cli file can contain multiple sites using [section] headers:
# Default site (used when no --site flag)
GHOST_URL=https://myblog.com
GHOST_ADMIN_API_KEY=id:secret
[staging]
GHOST_URL=https://staging.myblog.com
GHOST_ADMIN_API_KEY=id:secret
[client-blog]
GHOST_URL=https://client.example.com
GHOST_ADMIN_API_KEY=id:secretUse with the --site flag:
ghost-cli --site staging list posts
ghost-cli --site client-blog publish my-post
ghost-cli list posts # uses defaultCommands
List content
ghost-cli list posts # all posts
ghost-cli list posts --status draft # drafts only
ghost-cli list posts --status published # published only
ghost-cli list pages # all pagesCreate a draft
ghost-cli draft my-post-slug "My Post Title" content.mdCreates a draft post from a markdown file. If the file starts with # Title, the first line is stripped (the title comes from the argument). If a post with that slug already exists, it's replaced.
Publish / Unpublish
ghost-cli publish my-post-slug
ghost-cli unpublish my-post-slugGet post details
ghost-cli get my-post-slugShows title, status, URL, preview link, tags, and excerpt.
Update content
ghost-cli update my-post-slug updated-content.mdReplaces the post content from a markdown file. Preserves title, tags, and status.
Delete
ghost-cli delete my-post-slugList tags
ghost-cli tagsShows all tags with post counts, sorted by usage.
How It Works
Uses Ghost's Admin API with JWT authentication. The CLI constructs JWTs from your Admin API key using Node's built-in crypto module — no external dependencies.
Posts are created using Ghost's mobiledoc format with a markdown card, which means your markdown is rendered by Ghost's markdown engine (including code blocks, links, images, etc.).
License
MIT — Clifford Meece
