AdvancedCode injection

Code injection

Restyle any part of Ventura with a few lines of CSS in Ghost's Code injection: the stable handles, the theme's own colour variables, rules for one colour scheme or one kind of page, and what to leave alone.

Ventura labels the parts of every page with stable names, so you can restyle it from Ghost Admin without editing the theme, and without your changes breaking at the next update.

You need a little CSS. If you have never written any, the copy-paste rules on the snippets page are the place to start.

Where to paste it

Go to Settings → Code injection.

Put CSS in Site header, wrapped in a <style> tag.

Save, then reload your site with Cmd/Ctrl + Shift + R.

<style>
  [data-region="masthead"] [data-part="logo"] { height: 56px; }
</style>

In Ghost Admin

The Code injection panel with a style block in Site header

On your site: the logo at 56px

The header with the logo grown to 56px by the rule

Site header is for CSS

A <style> tag belongs in Site header. Ventura never asks you to paste HTML: everything it builds from your own content (the newsletter hero's copy, the Topics section, the membership band's proof row, the join page's questions) comes from pages you publish, so the Site footer box stays free for analytics and the like.

The naming convention

Four attributes, and you can usually guess a handle rather than look it up.

AttributeMeansHow many per pageExamples
data-regionA large areaAbout one eachsite-header, home-feed, post-body, site-footer
data-componentA repeating unitManypost-card, tag-tile, pagination, membership-band
data-variantA flavour of the unit it sits onFollows its hostgrid, list, immersive, prev, next
data-partA piece insideManytitle, kicker, excerpt, image, logo

They compose from the outside in:

[data-region="home-feed"] [data-component="post-card"][data-variant="grid"] [data-part="title"] { … }

Using the theme's own colours

Ventura's colours are variables with a light and a dark value each, so a rule that uses them follows your accent colour and the reader's colour scheme.

VariableWhat it is
--vt-canvasThe page ground, a soft grey
--vt-surfaceCards, panels and the header, white
--vt-subtleTinted panels: the Topics band, chips, the picks box
--vt-line, --vt-line-strongHairlines and card edges; the darker border on controls
--vt-inkThe main text colour
--vt-mutedQuieter text
--vt-accentYour accent colour, as a fill (set under Design & branding)
--vt-accent-inkThe accent adjusted to read as text on the page
--vt-on-accent, --vt-on-accent-mutedText on top of the accent: buttons, the membership band
--vt-dangerError text
<style>
  [data-component="tag-tile"] [data-part="title"] { color: var(--vt-accent-ink); }
</style>

The same colours exist under Tailwind's names (--color-accent, --color-ink and so on) for the theme's own use; the --vt- names are the ones we promise to keep.

To change one of them, set it on html:not(.dark) for light mode and on .dark for dark mode. A value set on a bare :root applies in both schemes, which is rarely what a light grey wants.

Targeting one colour scheme

Dark mode is a dark class on the page, so:

<style>
  /* dark mode only */
  .dark [data-region="site-footer"] { background: var(--vt-surface); }

  /* light mode only */
  html:not(.dark) [data-region="site-footer"] { background: var(--vt-canvas); }
</style>

When Color scheme is set to Light or Dark, the class is fixed and the rule for the other scheme never applies.

Targeting one kind of page

Ghost puts its own classes on the <body>, which is the tidiest way to scope a rule:

body.home-template   [data-region="site-header"]   { … }   /* the homepage only */
body.post-template   [data-region="post-body"]     { … }   /* posts only */
body.page-template   [data-region="page-header"]   { … }   /* pages only */
body.tag-template    [data-region="archive-header"] { … }  /* topic pages */
body.author-template [data-region="archive-header"] { … }  /* author pages */
body.paged           [data-region="post-feed"]     { … }   /* page 2 onwards */

Each post and page also carries its slug (page-about) and each tag on a post its slug (tag-money). The two routed pages, /tags/ and /bookmarks/, carry no body class at all: scope those rules with [data-region="topics"] and [data-region="bookmarks"] instead.

What not to target

Three things to leave alone.

  • Anything a script is managing. The menu list the header rebuilds, the More pill's panel, the phone menu's dialog, the picks carousel's track, the video box, the feed view and the two table-of-contents mounts are measured and rewritten as the page runs, so a rule that changes their size, overflow or position fights the script and usually loses. Style a wrapper around them instead: the reference marks which handles those are.
  • Utility classes. Names like mt-8, text-lg and lg:grid-cols-4 come from the theme's build and are not a promise: a release can change them. Handles are the promise.
  • Ghost's own names, and Ventura's machinery. Anything starting data-portal, data-members- or data-ghost- belongs to Ghost; anything starting data-nav-, data-bookmark, data-toc, data-feed, data-picks, data-video-, data-share- or data-reading- is Ventura's own wiring. Select them if it helps, but never remove or rename them.

When a rule does not apply

  • Reload properly. Cmd/Ctrl + Shift + R. Ghost injects your CSS into every page, but your browser may still be holding the old one.
  • Check the handle exists on that page. Most handles only appear on the page that has that thing on it.
  • Specificity before !important. Ventura's own styles sit in cascade layers, so a plain rule from Code injection wins over them without !important. The article body and the editor's cards are the exception, styled outside the layers: there a longer selector ([data-region="post-body"] p) usually wins on its own, and !important is the honest tool when it does not.
  • Test in both colour schemes. A colour that reads beautifully in light mode can disappear in dark mode. Using the variables above avoids most of it.

These handles are a promise

Every handle in the reference is a documented, stable name. Renaming or removing one counts as a breaking change and is called out in the release notes, so a rule you write today keeps working through theme updates.