Normal view

How to add typographic fonts to WordPress block themes

TL;DR: Use the Create Block Theme plugin to bundle fonts in your theme with just a few clicks.

WordPress block themes allow you to add fonts to a theme by adding the font file assets to the theme folder and referencing them in the theme.json. Editing a JSON file manually does not deliver the best user experience. The good news is you can use the plugin to make this task much simpler without technical trade-offs.

Disclaimer: The plugin is for development only and is not intended for live production websites because it modifies the currently active theme. It was conceived as a tool to create new production-ready themes.

Step by Step

  1. Install the Create Block Theme plugin.
  2. Activate the theme you want to manage.
  3. Go to Appearance -> Manage Theme Fonts.
  4. Add/Remove the font faces you want.

FAQS

How are the fonts bundled in my theme?

The plugin stores the font assets in a sub-folder of your theme ( <your-current-theme>/assets/fonts/ ) and adds font family definitions to your theme.json file. This is the case no matter if you upload a local font asset or use the Add Google Font option.

The plugin removes both the theme.json definition and the font assets if you remove a font face.

How are the fonts enqueued?

WordPress takes the font faces you added using the plugin, which are listed in your theme.json, and automatically converts them to CSS font face definitions which are included in the HTML page downloaded by the user browser.

Will adding many fonts make my theme too heavy?

Yes and no, or not necessarily. That can be counter-intuitive so let’s explore it in more detail. 

WordPress references all the font files needed in your site CSS to let the browser know what font assets may need to download.

Even though WordPress references many fonts, modern browsers are optimized to only download the fonts that are used in the page being loaded. It is important to note that browsers calculate this considering just the current page loaded and not on a site-wide basis.

For example, if you include an ultra-thin variant of the Inter font family, but there is not a single element (ex: paragraphs, links, etc.) using Inter ultra-thin variant, the browser will not download this font asset. In this case, the performance penalty for including this font is nearly zero.

Should I add a massive quantity of font faces to my theme “just in case”?

No, both from a performance and design perspective, having a good font pair is always advisable over a proliferation of too many different fonts. Also, if the font is not in use, what’s the point of including it?

There is no magical number of font faces you can or should include. But usually, less is more. Sticking to the minimal quantity required to implement the aesthetics you are looking for is always a good idea.

Can I include variable fonts in my theme?

As with any other font file, you can add variable font assets using the “Add Local Font” option. The plugin will add the font definition and asset just like any other type of font. You can use it just like that or adjust more options related to variable fonts by editing the theme.json file.

Is this solution GDPR compliant?

Yes, because the plugin bundles the font files in your theme, and your WordPress instance will serve them. No third-party servers or tracking technologies are involved in serving the fonts to your users. You don’t need to request extra permissions from your users to include the fonts.

More info

Do you need a more detailed step-by-step guide? No worries! Check out this great video tutorial about how to use the plugin.

Follow up

Have any questions about fonts and themes? Ask in the comments!

Gutenberg Changelog #76 – The new developer blog’s public beta, Gutenberg 14.5 and 14.6, and what’s coming up in 6.2. 

Ryan Welcher and Birgit Pauli-Haack discuss the new developer blog’s public beta, Gutenberg 14.5 and 14.6, and what’s in the works for the block editor. Show Notes / Transcript Show Notes Connect with Ryan Welcher Announcements WordPress Developer Blog What’s released Gutenberg Plugin Documentation What’s in active development or discussed Transcript Birgit Pauli-Haack: Hello and […]

💾

Gutenberg Changelog #74 – Gutenberg 14.2, 14.3, WordPress 6.1, Style Variations in Theme Directory, Course on Gutenberg Data Layer

Birgit Pauli-Haack and Dave Smith discuss Gutenberg 14.2, 14.3, WordPress 6.1, Style Variations in Theme Directory and a Developer Course on Gutenberg Data Layer Show Notes / Transcript Show Notes Special Guest: Dave Smith WordPress 6.1 Community Contributions Gutenberg Plugin 14.2 Gutenberg Plugin 14.3 Release lead: Aaron Robertshaw What’s in the Works? Transcript Birgit Pauli-Haack: […]

💾

Gutenberg Changelog #72 Gutenberg 13.9, 14.0, WordPress 6.02, Themes and Design Tools

Birgit Pauli-Haack and Nick Diego discuss highlights from Gutenberg 13.9, 14.0, WordPress 6.02, Themes and Design Tools. Show Notes / Transcript Show Notes Nick Diego developer advocate at WP Engine, plugin developer and themes builder. He is also a core contributor. Running Triage sessions in the core editor channel and is on the WordPress 6.1 […]

💾

Gutenberg Changelog #70 – Gutenberg 13.7, Template Creation Enhancements and First Full-Site Editing Themes in Woo Commerce Marketplace

In this episode, Birgit Pauli-Haacj and Mary Job introduce Ryan Welcher and discuss Gutenberg release 13.7, more template creation enhancements, first full-site editing themes in the Woo Commerce marketplace and more. Show Notes / Transcript Music: Homer Gaines Editor: Sandy Reed Logo: Mark Uraine Production: Birgit Pauli-Haack Show Notes WordCamp Jinja, Uganda / Call for speakers Ryan Welcher on […]

💾

Gutenberg Changelog #69  – Gutenberg Releases, WordPress 6.0.1, the Create Block Theme

Birgit Pauli-Haack, and Mary Job talk with this week’s special guest Jorge Costa about Gutenberg Releases, WordPress 6.0.1, the Create Block Theme plugin and much more. Show Notes / Transcript Music: Homer Gaines Editor: Sandy Reed Logo: Mark Uraine Production: Birgit Pauli-Haack Show Notes Why You Should Try Out Block Themes Don’t miss it! A Block-First Approach at Pew Research […]

💾

Gutenberg Changelog #68 – WordCamp Europe, Gutenberg 13.4 and WordPress 6.1

Birgit Pauli-Haack, and Mary Job talk with this week’s special guest Dave Smith about WordCamp Europe, WordPress 6.1 and Gutenberg 13.4. You also learn what in the works via the GitHub repo. Show Notes / Transcript Show Notes Special Guest: Dave Smith, JavaScript Engineer and full-time Core Contributor on the Gutenberg project, sponsored by Automattic […]

💾

Gutenberg Changelog #67 Gutenberg 13.2 and 13.3, WordPress 6.0 and more

Birgit Pauli-Haack and special guest, Grzegorz Ziolkowski talk about WordPress 6.0 release, Gutenberg 13.2 and 13.3 and interesting discussions happening on the Gutenberg Repo Show Notes / Transcript Show Notes WordPress 6.0 Community Contributions What’s Released Gutenberg 13.2 Gutenberg 13.3 What’s being worked on or discussed Transcript Birgit Pauli-Haack:  Hello, and welcome to our 67th […]

💾

Gutenberg Changelog #66 – Gutenberg 13.1, New Zealand, InnerBlocks

Birgit Pauli-Haack and Mary Job discuss with their guest, Glen Davies, Gutenberg 13.1, New Zealand, InnerBlocks and more so much more. Music: Homer Gaines Editor: Sandy Reed Logo: Mark Uraine Production: Birgit Pauli-Haack Show Notes / Transcript Show Notes Glen Davies on Twitter GlenDavisNZ.blog FSE Program Rallying Recipe Reviewers Play the Piano and Other Instruments via the WordPress Block […]

💾

Gutenberg Changelog #65 – Gutenberg 13.0, WordPress 6.0, Inline Token Proposal and more

Birgit Pauli-Haack and Mary Job discuss with their guest, Dennis Snell, Gutenberg 13.0, WordPress 6.0, an Inline Token Proposal and so much more. Music: Homer Gaines Editor: Sandy Reed Logo: Mark Uraine Production: Birgit Pauli-Haack Show Notes / Transcript Show Notes Special guest: Dennis Snell, WordPress core contributor and JavaScript wrangler at Automattic. Dennis Snell’s post on WordPress and […]

💾

Gutenberg Changelog #64 – Gutenberg 12.9, Example Repo, and Inline Tokens

Birgit Pauli-Haack and Mary Job talked about Gutenberg 12.9 new features and enhancements, updates to the Gutenberg Example Repo and share a post on how to implement inline tokens for Rich Text. And so much more. Music: Homer Gaines Editor: Sandy Reed Logo: Mark Uraine Production: Birgit Pauli-Haack Show Notes / Transcript Show Notes Announcements WPAfrica Community Call for […]

💾

Gutenberg Changelog #63 – Block Pattern Directory, WebFonts API and Gutenberg 12.8

Birgit Pauli-Haack and Mary Job discuss Block Pattern Directory, WebFonts API and Gutenberg 12.8. Music: Homer Gaines Editor: Sandy Reed Logo: Mark Uraine Production: Birgit Pauli-Haack Show Notes / Transcript Subscribe to the Gutenberg Changelog podcast via your favorite podcast apps!🎙️ Spotify | Google | iTunes | PocketCasts | Stitcher |🎙️ Pod Bean | CastBox | Podchaser | RSS Feed  Show Notes Announcements FSE Program: Bring your questions – Round Three Coming soon: Block Pattern Directory Submissions Community […]

💾

Gutenberg Changelog #62 – Gutenberg 12.7, a New Call for Testing, the Web Fonts API Arrival

In this episode, Birgit Pauli-Haack and Mary Job discuss Gutenberg 12.7, a new call for testing and the web fonts API arrival. Music: Homer Gaines Editor: Sandy Reed Logo: Mark Uraine Production: Birgit Pauli-Haack Show Notes / Transcript Subscribe to the Gutenberg Changelog podcast via your favorite podcast apps!🎙️ Spotify | Google | iTunes | PocketCasts | Stitcher |🎙️ Pod Bean | CastBox | Podchaser | RSS Feed  Show Notes FSE Program Testing Call #12: Hyping Headers Gutenberg […]

💾

Block Theme Building Tips

When building block themes there is often more than one way to achieve the same thing. It’s often not clear which of these options is preferable. Below I outline some tips and guidelines that I find helpful. The guiding principle here is to remove as much complexity as possible from the theme; instead block themes should be using the affordances provided by Gutenberg.

1. Avoid using CSS

As much as possible, block themes should avoid providing CSS. Gutenberg increasingly offers design tools which allow theme builder to control the design of the theme without using CSS. If it is not possible to achieve a particular design without CSS please create an issue for it on Gutenberg so we can consider adding a design tool to achieve the design.

2. Reuse patterns rather than implementing custom templates

As the number of block themes we build grows we will have an ever increasing number of templates and template parts in each theme. In practice there are a small number of patterns which can be reused on many themes. We should be aiming to reuse existing patterns rather than implementing new templates. This means we need clever patterns which are able to reuse settings from theme.json.

3. Prefer theme.json to block settings

Connected to the point above, when we want to change the appearance of a block in a template or a pattern it is usually better to do so in the theme.json file than in the block template. This means that the design will be used for all instances of the block, not just the edited instance. It also keeps templates design agnostic, so that they be reused (see above).

What other tips do you have for building block themes?

Gutenberg Changelog #61 – Gutenberg 12.6, Planning for WordPress 6.0 and Universal Blocks

Grzegorz Ziolkowski and Birgit Pauli-Haack introduce Mary Job as the new co-host and discuss Gutenberg 12.6, Planning for WordPress 6.0 and Universal Blocks. Music: Homer Gaines Editor: Sandy Reed Logo: Mark Uraine Production: Birgit Pauli-Haack Show Notes / Transcript Subscribe to the Gutenberg Changelog podcast via your favorite podcast apps!🎙️ Spotify | Google | iTunes | PocketCasts | Stitcher |🎙️ Pod Bean | CastBox | Podchaser | RSS Feed  Show Notes New co-host: Mary Job Mary Job’s Profile […]

💾

Gutenberg Changelog #60 – Restricting Customization in a Full-Site Editing World, Gutenberg 12.5 and Roadmap for WordPress 6.0

Birgit Pauli-Haack and Grzegorz Ziolkowski discuss with their guest Matias Ventura restricting customization in a full-site editing world, Gutenberg 12.5 and Gutenberg changes coming with WordPress 6.0. Music: Homer Gaines Editor: Sandy Reed Logo: Mark Uraine Production: Pauli Systems Show Notes / Transcript Subscribe to the Gutenberg Changelog podcast via your favorite podcast apps!🎙️ Spotify | Google | iTunes | PocketCasts | Stitcher |🎙️ Pod Bean | CastBox | Podchaser | RSS Feed  Show Notes Twitch Stream session […]

💾

❌