Change Casper Fonts with Google Fonts
In this tutorial, I will show you how to change the Casper Ghost CMS theme’s fonts using Google Fonts.
The Casper theme is using two different fonts:
- Georgia for the post content and excerpts.
- UI System Fonts for everything else.
Suppose you want to use the Roboto Google font instead of the theme UI System Fonts.
In Ghost Admin, open Code Injection → Site Header. Add the code from Google Fonts:
<link href='https://fonts.googleapis.com/css2?family=Roboto:wght@300;700&display=swap' rel='stylesheet'>
You can choose different font styles depending on your needs. In this example, I chose the 300 and the 700 weights.
The next step is to assign the Roboto font to the body element using CSS.
<style>
body {
font-family: 'Roboto', sans-serif;
}
</style>
The Code Injection area will look like this:
Change the Font of a Specific Element
If you want to change the font of a specific element, you need to get the element’s class name. You can use the browser development tools to do that.
You can use Chrome DevTools or Firefox Developer Tools. Right-click an element on the page and choose Inspect. Chrome opens the Elements panel. Firefox opens the Inspector panel. Also, you can press Command+Option+C (Mac) or Control+Shift+C (Windows, Linux, Chrome OS) to open the inspection panel.
Find the element’s CSS class. For the post excerpt, it is .post-card-excerpt. Assign the font to that class:
<style>
.post-card-excerpt {
font-family: 'Roboto', sans-serif;
}
</style>
Click the Inspect icon to select another element on the page. You can then find its class.
If you want to set the font size for an element, you can use the CSS font-size property to do that. This example sets both the font family and font size:
<style>
.post-card-excerpt {
font-size: 16px;
}
</style>
To wrap all the code, we have done so far; it could look like the following in Code Injection.
<link href='https://fonts.googleapis.com/css2?family=Roboto:wght@300;700&display=swap' rel='stylesheet'>
<style>
body {
font-family: 'Roboto', sans-serif;
}
.post-card-excerpt {
font-family: 'Roboto', sans-serif;
font-size: 16px;
}
</style>
Don’t worry if you didn’t grasp how the CSS code works at first. If you are curious to learn more, I would recommend the Learn web development resource by Mozilla.
More from the Blog
Latest Ghost Themes
Arish
For visual magazines that lead with photography, film, and selected stories.
Siwa
A personal publication that introduces the writer before inviting readers into the stories.
Hanoi
An image-led magazine for creative stories, rich navigation, and long-form reading.
Taba
A newsroom front page for coverage across topics, video, and story formats.
Marsa
A flexible publication homepage for featured stories, topics, and newsletters.
Hakone
For writers who want readers to browse complete posts on the homepage.