Learn to delete empty tags in Ghost via the Admin API. Sadly, for whatever reason the creators of Ghost, even in version 4, have not provided us with an interface way of bulk editing things. As such, the only way to do something in bulk is via the API.
The Content API doesn't allow for deletion (of tags) and so, we'll be using the Admin API /tags/
route (which currently is in beta according to their documentation) in-order to do what we want.
At the bottom of this article, I've embedded a link to the script I wrote. All you'll need is:
- Python 3 (I used py3.9)
- Python module:
requests
- Python module:
pyjwt
❗
Do NOT use the
jwt
module. It does not have the functions to handle security and authorization stuffs so it will not work. pyjwt
is the module you need to install for this to work.Once you have all your pieces here are the four (4) easy steps to delete all your blog's empty post tags:
- Get your Ghost ADMIN API key (not the content api, the admin api key)
- Download the script from the GIST below
- Edit lines 6 and 7. Line 6 is the admin key, put yours there, and then add your domain for line 7. Save.
- Run the script.
Done.
The script does the following:
- Generated a JWT token from your provided Admin API key
- Authenticates into your Ghost instance using said token
- Gets the IDs of all your EMPTY tags
- Then deletes all of said tags
Feel free to check out the comments on the script for more details.