Most changes people want from a theme are small: a different font, a warmer background, a hidden credit line. You can make all of them from Ghost Admin with a few lines of CSS. No download, no build step, and your changes survive theme updates.
Where custom CSS goes
Open Settings → Code injection, and put your CSS in Site header inside a <style> tag:
<style>
/* your changes */
</style>
Save, then refresh your site. Everything in this guide goes in that one box.
Fonts
The easiest way needs no CSS at all: open Settings → Design & branding → Brand → Typography and pick a heading font and a body font. Attegi uses them straight away.
To use a font Ghost does not offer, load it and point Attegi's two font variables at it. For example, a serif body for a literary blog:
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,[email protected],400;8..60,600&display=swap">
<style>
:root {
--gh-font-body: "Source Serif 4", Georgia, "Songti SC", serif;
}
</style>
Keep a Chinese font such as "Songti SC" or "PingFang SC" at the end of the list if you write in Chinese. Western web fonts have no Chinese characters, and this tells the browser what to use instead.
Colors
Attegi's colors are CSS variables with a light value and a dark value. Override the ones you want, and do it for both modes, or dark mode will keep the old colors.
/* Light mode */
:root {
--color-background-main: #FBF8F3; /* page background */
--color-background-secondary: #F3EEE6; /* cards, code, callouts */
--color-content-main: #3B342C; /* body text */
}
/* Dark mode, when the reader picks it */
.theme-dark:root {
--color-background-main: #1B1A18;
--color-background-secondary: #24221F;
--color-content-main: #E6E0D6;
}
/* Dark mode, when the device asks for it */
@media (prefers-color-scheme: dark) {
html:not(.theme-light):root {
--color-background-main: #1B1A18;
--color-background-secondary: #24221F;
--color-content-main: #E6E0D6;
}
}
The dark block appears twice on purpose. The first covers readers who choose dark mode with the footer button, the second covers readers whose device is set to dark.
The variables you will most likely want:
| Variable | Used for |
|---|---|
--color-background-main |
Page background |
--color-background-secondary |
Cards, code blocks, callouts |
--color-content-lead |
Headings and titles |
--color-content-main |
Body text |
--color-content-secondary |
Dates, captions, muted text |
--color-border |
Hairlines and dividers |
--color-highlight |
Background of highlighted text |
For the accent color, use Brand → Accent color and the Dark mode accent color setting rather than CSS. Attegi calculates readable text colors from those two values, and a CSS override would skip that.
Small recipes
Hide the "Published with Ghost & Attegi" line
.footer-credits { display: none; }
We would be grateful if you kept it, but it is your site.
Style one tag differently
Every post carries a class for each of its tags, such as tag-poetry. Use it to give a series its own look:
.tag-poetry .post-content {
font-family: "Songti SC", Georgia, serif;
}
Give a tag its own icon
On the Tags page, tags without a feature image show an icon. To choose it, open the tag in Tags, go to its Code injection → Tag header, and paste an SVG inside a template:
<template data-tag-icon>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<path d="M4 19.5V5a2 2 0 0 1 2-2h13v16H6a2 2 0 0 0-2 2z"/>
</svg>
</template>
The tag's accent color, if you set one, tints the icon.
Keep one heading out of the table of contents
Write the heading in an HTML card and give it a class:
<h2 class="js-toc-ignore">Appendix</h2>
A link card anywhere
The cards on the Links page can be used in any post with an HTML card:
<div class="link-card">
<a href="https://example.com" class="link-card-container">
<div class="link-card-content">
<div class="link-card-title">Example</div>
<div class="link-card-description">A short description of the site.</div>
</div>
</a>
</div>
Before you ship
- Check light mode and dark mode. The theme button is in the footer.
- Check a phone-sized window. Most readers are on one.
- Keep it small. If your Code injection box grows past a screen or two, it is time for a fork.
Comments