Meet the {{content_api_key}} helper for Ghost

Your theme now has direct access to the Content API key. Integrators, rejoice!

Meet the {{content_api_key}} helper for Ghost

Introducing what's possibly the smallest Ghost helper! In Ghost 5.96 and above, you can now use {{content_api_key}} to get (drumroll please!) the site's Content API key. This is a helper, so it works in .hbs files in the theme. (Not in code injection.)

What's it good for? Integrations! Some themes integrate third party scripts that need to retrieve data from the Content API. Previously, there wasn't a great way to do this. (Theme creators have sometimes required users to get the key from the integrations part of the admin dashboard and paste it into the design. It's also been possible to get it from the portal or search javascript, but that's a bit clunky. This should hopefully simplify the process of including scripts that use the Content API into themes.

Those of you reading closely may remember that this helper was on my three-item list of what it'd take to replicate {{ghost_head}}. Stay tuned...


Interested in how to add a helper to Ghost? Here's the PR that created this one:

✨Add content_api_key helper by cathysarisky · Pull Request #21151 · TryGhost/Ghost
This very small helper adds {{contentkey}} to the collection of handlebars helpers available to theme creators. This will make it easier for themes to access the content API key, without either req…

Yep. 19 lines of actual code, 19 lines of tests for that code, plus one line to get Ghost to recognize it.


OK, OK, I won't actually keep you in suspense about ghost_head. I had a great conversation with the Ghost team about it, and we've settled on the idea of allowing themes to exclude parts of ghost_head, by way of an extra configuration setting in the theme's package_json. That's going to open up a whole lot of options for changing how themes work.

But first, someone has to write that, and I'm still wrangling i18n issues...