More than just a formatting toolbar, the rich editing experience within Ghost allows authors to pull in dynamic blocks of content like photos, videos, tweets, embeds, code and markdown. For author-specified options to work, themes need to support the HTML markup and CSS classes that are output by the
{{content}}
helper. Use the following examples to ensure your theme is compatible with the latest version of the Ghost editor.
<figure>
and <figcaption>
Images and embeds will be output using the semantic <figure>
and <figcaption>
elements. For example:
.kg-image-card
is used on the<figure>
element for all image cards.kg-image
is used on the<img>
element for all image cards.kg-embed-card
is used on the<figure>
element on all embed cards
<figure>
elements to maintain compatibility with the Markdown and HTML cards.
Image size options
The editor allows three size options for images: normal, wide and full width. These size options are achieved by addingkg-width-wide
and kg-width-full
classes to the <figure>
elements in the HTML output. Here’s an example for wide images:
width
and height
attributes when that data is available. Width and height correspond to the size and aspect ratio of the source image and do not change when selecting different size options in the editor. If your theme has a max-width
style set for images it’s important to also have height: auto
to avoid images appearing stretched or squashed.
The specific implementation required for making images wider than their container width will depend on your theme’s existing styles. The default Ghost theme Casper uses flexbox to implement layout using the following HTML and CSS:
Negative margin and transforms example
Traditional CSS layout doesn’t support many elegant methods for breaking elements out of their container. The following example uses negative margins and transforms to achieve breakout. Themes that are based on Casper use similar techniques.Responsive image sizes
Where possible images will havesrcset
and sizes
attributes to allow for smaller images to be served to devices with smaller screens. Full output will look similar to this:
Editor cards
Each of the content cards available in the editor require CSS and Javascript to display and function correctly. These default CSS and Javascript assets are provided automatically by Ghost, and output ascards.min.css
and cards.min.js
in the {{ghost_head}}
helper.
You can override the default styles and behaviour for individual cards by configuring your theme’s package.json
to exclude the assets for specific cards:
card_assets
to false (the default is true).
audio
, blockquote
, bookmark
, button
, callout
, file
, gallery
, header
, nft
, product
, toggle
, video
, and signup
.
You can customize the styles of individual cards by using custom CSS. Each card has a unique class name that you can target to apply your own styles. Here’s a list of the class names for each card type:
- Audio:
.kg-audio-card
- Blockquote:
blockquote
or.kg-blockquote-alt
- Bookmark:
.kg-bookmark-card
- Button:
.kg-button-card
- Callout:
.kg-callout-card
- File:
.kg-file-card
- Gallery:
.kg-gallery-card
- Header:
.kg-header-card
- NFT:
.kg-nft-card
- Product:
.kg-product-card
- Toggle:
.kg-toggle-card
- Video:
.kg-video-card
- Signup:
.kg-signup-card
Gallery card
The image gallery card requires some CSS and JS in your theme to function correctly. Themes will be validated to ensure they have styles for the gallery markup:.kg-gallery-container
.kg-gallery-row
.kg-gallery-image
Bookmark card
Here’s an example of the HTML structure that’s created by the editor:Embed card
If a video is used with the theme then some CSS will be needed in order to maintain a good aspect ratio. Example HTML:NFT card
NFT embeds are provided by OpenSea. Example HTML:Button card
Button cards insert a link that is styled like a button using the site’s configured accent color and can be left or center aligned. Example HTML:Callout card
Callout cards show a highlighted box with an emoji and a paragraph of text. Example HTML:Toggle card
Toggle cards show a collapsible content box with heading and arrow icon. Example HTML:Alternative blockquote style
There are two styles of blockquote available that can by cycled through by repeatedly pressing the blockquote toolbar icon. Example HTML:Audio upload card
Audio card allows uploading custom audio files. Example HTML:Video upload card
Video card allows uploading custom video files. Example HTML:File upload card
File card allows uploading custom files for download. Example HTML:Header card
The header card gives you the ability to add headers to your posts and pages. Example HTML:kg-size-
class of either: kg-size-small
, kg-size-medium
or kg-size-large
and a kg-style-
class of either kg-style-dark
, kg-style-light
, kg-style-accent, or
kg-style-image`.
The default CSS for the card can be used as a reference implementation.
Signup card
The signup card adds a customizable signup form to posts. (Only available in the new beta editor.)kg-width-<size>
, size
can be kg-width-regular
, kg-width-wide
, or kg-width-full
.
Full-width and split-layout with contained image cards provide a kg-content-wide
class. Use this class to ensure card content is properly positioned and sized. See Casper’s implementation for a guide.
Split-layout signup cards, which include an image adjacent to the text content, provide the kg-layout-split
class.
See the default CSS included with this card.