TL;DR
Ghost 2.22.0: Enhanced Code Cards and HTML Handling
Ghost 2.22.0 introduces significant improvements to code cards with caption support and language selection, along with enhanced HTML handling capabilities in the Admin API. This release also fixes several critical bugs including post scheduling issues, private blogging password submission, and collection routing problems. The default Casper theme has been updated to version 2.10.0 to support the new code card features.
Highlight of the Release
- Added caption support and language selection for code cards
- Improved HTML handling in the Admin API with HTML card parsing
- Fixed critical post scheduling bug that prevented scheduled posts from publishing after restart
- Fixed password submission for private blogging
- Added protocol overwrite support for canonical URLs to maintain social engagement metrics
Migration Guide
Theme Updates for Captioned Code Cards
If your theme needs to support captioned code cards, you'll need to update your CSS styling. Non-captioned code cards will continue to render as before:
<pre><code>...</code></pre>
However, captioned code cards will now be rendered inside a <figure> element:
<figure class="kg-card kg-code-card">
<pre><code>...</code></pre>
<figcaption>...</figcaption>
</figure>
For reference on required styling changes, check the Casper theme PR #575.
HTML Card Parsing
When sending HTML content with ?source=html to the v2 Admin API, you can now include blocks of HTML that will be extracted to HTML cards:
<p>Some standard content...</p>
<!--kg-card-begin: html-->
<div class="my-custom-html">...</div>
<!--kg-card-end: html-->
<p>Some more content...</p>
This will create an HTML card in the mobiledoc with the content <div class="my-custom-html">...</div>.
Upgrade Recommendations
This release contains several important bug fixes and feature enhancements that improve content creation capabilities and fix critical issues with post scheduling and private blogging.
Who should upgrade immediately:
- Sites using scheduled posts (fixes a long-standing bug since Ghost 2.12)
- Sites using private blogging
- Sites using collection routing with data.slug
- Windows-based Ghost installations
Theme developers should review the code card caption implementation and update their themes accordingly to properly support the new captioned code cards.
The upgrade process follows the standard Ghost update procedure and should be straightforward for most installations.
Bug Fixes
Critical Fixes
- Fixed post scheduling on restart (issue existed since Ghost 2.12)
- Fixed password submission for private blogging that was broken due to request stream consumption
- Fixed 404 errors in collection index page when using data.slug
- Fixed meta schema for 'page' context in dynamic routing
UI and Content Fixes
- Fixed Twitter card having wrong property when no feature image but a dedicated Twitter image is provided
- Fixed postinstall script when running on Windows by replacing Unix-specific commands
- Fixed member permission/role relations in fixtures
- Added temp file cleanup for invalid themes
New Features
Code Card Enhancements
- Added caption support to code cards, allowing content creators to provide context for code snippets
- Added language selection for code cards, enabling proper syntax highlighting
- Code cards with captions are now rendered inside a
<figure> element with appropriate classes
Improved HTML Handling
- Added parsing of HTML cards when converting HTML via the v2 Admin API
- Added caption and language extraction for code blocks when converting HTML via API
- HTML blocks can now be extracted to HTML cards rather than going through normal lossy HTML-to-mobiledoc conversion
Canonical URL Improvements
- Added protocol overwrite support for canonical URLs
- Only transforms canonical URLs to relative when the protocol matches the blog URL
- Helps maintain Facebook comments/shares/likes when moving from
http to https
Security Updates
No specific security fixes were mentioned in this release.
Performance Improvements
Code Improvements
- Updated reading time helper to use SDK method instead of duplicate calculation
- Updated to use slugify method from SDK for safe string
- Removed
lts update check flag as support was discontinued
- Added more comprehensive comments and documentation for Ghost API and post scheduling
- Moved cpy-cli to dependencies to ensure it's available in all install contexts
Impact Summary
Ghost 2.22.0 delivers significant improvements to content creation workflows with enhanced code cards that now support captions and language selection. This makes technical content more readable and maintainable. The release also fixes several critical bugs that have affected core functionality, including a long-standing issue with post scheduling that has existed since version 2.12.
The improvements to HTML handling in the Admin API provide more flexibility for developers and content creators working with complex HTML content, allowing for better preservation of custom HTML when importing content.
Site owners will benefit from fixes to private blogging, Twitter card properties, and canonical URL handling, which collectively improve the user experience and SEO capabilities of Ghost sites.
The default Casper theme has been updated to version 2.10.0 to support the new code card features, providing a reference implementation for other theme developers.
Overall, this is a feature-rich release that addresses several important bugs while adding valuable enhancements to content creation capabilities.
Full Release Notes
- ✨ Added caption support to code cards - Kevin Ansfield
- ✨ Added language selection to code cards (#1180) - Kevin Ansfield
- ✨ Added parsing of html cards when converting HTML via the v2 Admin API - Kevin Ansfield
- ✨ Added caption and language extraction for code blocks when converting HTML via API - Kevin Ansfield
- 🎨 Allowed protocol overwrite for canonical URLs (#10729) - Aileen Nowak
- 🐛 Fixed password submission for private blogging - Fabien O'Carroll
- 🐛 Fixed post scheduling on restart (#10726) - Katharina Irrgang
- 🐛 Fixed Twitter card having wrong property when no feature image provided - Aileen Nowak
- 🐛 Fixed postinstall script when running on Windows - Fabien O'Carroll
- 🐛 Fixed meta schema for 'page' context in dynamic routing - Nazar Gargol
- 🐛 Fixed 404 in collection index page if using data.slug - Nazar Gargol
Casper (the default theme) has been upgraded to 2.10.0:
- ✨ Added support for code cards with captions (#575) - Kevin Ansfield
You can see the full change log for the details of every change included in this release.
Note on captioned code card support in themes:
Non-captioned code cards will continue to render as before:
<pre><code>....</code></pre>
Captioned code cards will be rendered inside a <figure> element and may require changes to theme styles for full support:
<figure class="kg-card kg-code-card">
<pre><code>...</code></pre>
<figcaption>...<figcaption>
</figure>
For an example of required styling changes see this PR on Casper