Understanding how the Create Block Theme plugin works

In this post I explain how you can design a block theme from scratch with a plugin and without touching any code.

diseñador pensando diseño de un tema

For those of us who have been watching WordPress evolve for a few years now (and I’m far from the oldest around), since Full Site Editing came into our lives we’ve been constantly amazed. If someone had told me 10 years ago that today I could create a WordPress theme without touching a single line of code, from absolute scratch or starting from any block theme, I wouldn’t have believed it for a second.

Well, that’s what the official community plugin Create Block Theme lets you do. The only problem is that you need to understand certain concepts about how Full Site Editing (FSE from now on) works, so you don’t end up throwing yourself off the Eiffel Tower after failing to create a new design. Let alone a theme.

A small warning.

Since the same thing could happen to you as happened to me, let me warn you before it does.

To work with this plugin, under no circumstances should you have WordPress debug mode enabled in any of its “flavors”:

  • define( 'WP_DEBUG', false );
  • define( 'SCRIPT_DEBUG', false );

If you had them enabled, you’d find that you can work, but at some point, probably sooner rather than later, the plugin won’t do things correctly and you’ll have thrown your work away.

Don’t say I didn’t warn you 😉

How does Full Site Editing work at the most basic level?

The first thing to understand is what happens when we add design to our site using block patterns. As you may know, WordPress has a database with different tables, and if you didn’t know, I’m telling you now. Without going into detail, one of those tables is wp_posts. It stores many things related to content, such as custom post types, but also block patterns, among many other things.

A quick aside: to write this post, I created a site from scratch locally (with the help of Local), and I made changes to the site while watching how those changes were reflected both in the wp_posts table and in the folder of the active theme. For this, I used the Powder theme by Brian Gardner, a simple theme that offers interesting design patterns.

The initial version of the theme I installed was 1.0, so I could update it and see what happened, whether I lost changes, and so on. This way I was able to explore and understand how this great plugin works. End of aside.

Back to what we were talking about. With a fresh WordPress install, the wp_posts table had only four records, which grew to eight when I created a home page.

Naturally, after installing the Powder theme, creating a template for the home page and adding several patterns to make that page look half decent, the table gets a few more records. So we start with a table of ten records.

From here, we begin our tour of Create Block Theme and try to understand its internal effects on WordPress.

The new Create Block Theme menu: cross-cutting options

Previously, Create Block Theme was used from the WordPress admin panel, under Appearance > Create Block Theme, where you could do tasks such as creating a child theme, cloning the theme, etc.

But recently (at the time of writing), that screen tells us to go to the Site Editor, where we’ll find a new menu that brings together all of CBT’s features, and the old panel will be removed in the near future.

It makes sense, since everything related to design should happen in the Site Editor. The menu looks like this:

Create Block Theme plugin menu in the editor
The plugin’s menu in the block editor

To keep things simple, let’s go over the minor features and those that cut across the rest, from least to most important. Don’t worry: although it may seem confusing, it’s better this way because we’ll use these features later, and I don’t want to interrupt the explanation of the complex part to explain a minor feature.

View theme.json

The foundation of block themes is a file called theme.json. It’s a data file in JavaScript Object Notation that stores the theme’s main design settings. For example, if you choose a particular color style, if you also add a custom color for your brand, if you add your brand’s typeface (that could fill another post), etc. All that information is stored in the theme.json file, which you’ll normally find in the root of the active theme or child theme. We’ll talk about that later too.

This option is nothing special: it simply lets us view the theme.json file, so we can check whether there’s anything odd that we’ve noticed while working on the design.

It’s true that it’s code, but it’s very simple code, very similar to CSS or even easier to understand.

Edit Theme Metadata

No secrets here. As you know, when you install a theme, it comes with a set of metadata:

  • Title
  • Description
  • Author
  • Author’s website
  • The author’s life story…

Here you get the chance to edit this data, which will be saved in the theme files. So keep in mind that if we change the metadata of a parent theme, when a new update arrives we’ll lose all the changes we made.

Export Zip

This one’s clear: it creates a .zip file that we download to our computer. If a parent theme is active, we can take this .zip straight to any other WordPress site and install it as a theme.

If it’s a child theme, obviously the parent theme will need to be installed for the theme’s design to show up.

Options for consolidating changes

Having seen the minor (but not trivial) options, and going against every content creation rule that says important things first and less important things last, let’s look at two options that are essential for understanding the theme creation features the plugin offers.

Save Changes to theme

Seems pretty obvious, right? Save the changes to the theme. But where do we save them? If you read the first section and didn’t hop ahead like a grasshopper, I explained at the start that any change we make in the Site Editor, any new pattern we create, any new template we create, etc., is saved in the database.

This is something we’ve always tried to avoid. The less in the database, the better. Well, yes, but it’s not that big a deal. However, if we have a super-complicated design, we may end up building a monster.

This option consolidates all the changes we’ve made into files inside the theme. But let’s see which changes we can save.

When you click this plugin option, a submenu appears with some boxes checked and others unchecked. The menu looks roughly like this:

Submenu of the save changes to theme option
The default options of Save Changes to Theme.

Each option does the following:

  • Save Fonts: Since WordPress 6.5 we can manage fonts locally. This option saves the active fonts to the theme and removes the inactive ones from it.
  • Save Style Changes: If we check this box, the global styles we’ve configured in the editor will be saved to our theme.
  • Save Template Changes: Exactly the same as the previous box but for templates and template parts.
  • Process Only Modified Templates: It will process only the templates we’ve modified in the editor, not the rest.
  • Localize Text: Any text we change in a template will be copied to a pattern and saved locally in the theme.
  • Localize images: Like the previous option, if we add an image to the theme’s design, it will be saved with the theme so it can be moved along with it and we don’t end up with an orphaned image when installing the theme on another site. These images are saved in a local folder inside the theme called /assets.
  • Remove Navigation Refs: Removes any theme references, returning the navigation block to its default state.

Naturally, the first four options are enabled by default, and the rest will depend on whether we’ve changed any of the elements they affect.

The important thing to understand about this option is that when we run it, the changes are saved in the active theme’s folder. For example, on the test site I’ve been working on, we can see that two files change:

Files modified with save changes
With Save Changes, these files would be modified.
  • On the one hand, the front-page.html file changes, which is nothing more than the HTML dump with Gutenberg block notation.
  • On the other hand, the other file that has changed is, naturally, theme.json, where all the style settings that were being stored in the database have been saved.
We can see some changes inside the theme json saved in the theme.
Changes made in theme.json.

All of this will be removed from the database. Or not, because in the different tests I ran, the behavior varied from one to another. Keep in mind that the plugin is under constant development and is an experimental plugin, at least at the time of writing.

Watch out, there’s one very important thing to keep in mind. What happens if we update the theme?

  • If we’ve gone in all guns blazing and saved all the changes directly to the parent theme we liked and installed in the first place, we’ll lose everything. Remember that both plugins and themes, when updated, wipe out all the files from the previous version and replace them completely, since settings are stored in the database.
  • However, if we’ve been good, we’ll have created a child theme, which inherits the parent theme’s properties, so the parent theme will be updated but our changes will be preserved in the child theme.

I think you’re starting to see the right way to work with this plugin.

Create Theme Variation

This option is meant for when, starting from one of the theme’s style variations, we customize it with our own fonts, brand colors, etc., and want to create a new theme variation.

This isn’t for layouts, but for basic design settings. That is, what we see in the style variations we can choose in the sidebar of the style editor.

When we decide to save a variation of the global styles with the Create Theme Variation option, a window like this appears in the editor:

Create theme variations dialog box
This is the window that appears when we’re about to save a style variation.

And when we save, our changes will be stored in a .json file with the name we gave that style variation, inside the theme’s /styles/ folder.

Location of the style variation in the theme's folder
Location of the style variation’s .json file in its folder.

Of course, when we save to the file, the entries that had been recorded in the wp_posts table will be removed, since they’ve now been moved to the theme.

Again, if you consolidate these changes in the parent theme, you’ll lose them when you update it. But if you do it on a child theme, like civilized people, these changes will be kept regardless of updates.

When updating the parent theme, if you’ve done everything on it, some elements may keep the custom colors you assigned. That’s because those changes are stored in the database and not in the theme itself. That’s why they aren’t lost.

The theme creation options

Having seen the options for modifying themes, let’s now look at the options for creating themes in different ways.

Basically we have three options. Although you see two, Create Blank Theme and Create Theme, inside Create Theme you’ll actually find two more: Clone Theme and Create Child Theme.

Create Blank Theme

This option is clear: it’s the one that lets us create a theme completely free of styles. In fact, when you run it and the new theme is created, you’ll see that everything looks very bare. That’s because the basic files needed for a theme have been created, but nothing more: no styles, no fonts, no colors, absolutely nothing at all.

If you’re a designer and want to create a theme from scratch without touching any code, this is your option. Well, I won’t lie to you: you may end up having to touch a bit of code, but it’ll be CSS or not much more. Usually it won’t be necessary.

Where is this theme created? As another folder inside /wp-content/themes/, and this folder will contain the basic files a newly created theme needs. The theme will also appear in the WordPress admin like any other theme:

On the other hand, keep in mind that from now on you’re footing the bill. That is, since it’s a new theme created by you, you’ll be responsible for any future updates needed to keep it compatible with new versions of WordPress, because nobody else will be sending you updates.

In principle, there shouldn’t be much trouble, but life changes and who knows what the future will bring.

Create Theme

This option is a bit absurd, and I wouldn’t rule out it changing and forcing me to update this post. Obviously, with the previous option we already created a theme, so what are we going to do now…? Exactly.

Inside this option there’s a submenu with two more options:

Create Theme options
Create Theme options
  • Clone Theme: With this option we clone the active theme, creating a new, similar theme, since it copies all of the original’s files. But be careful: just like with Create Blank Theme, it will no longer receive any kind of support, and updates will be up to us.
  • Create Child Theme: You’ve probably guessed that this is my favorite option. It creates a child theme, with only the files needed to inherit the parent theme’s properties, and where the child theme’s particular features, which the parent theme doesn’t have, are saved.
    Thanks to this option we can keep enjoying the updates the parent theme receives, and we only take care of the part we created ourselves.

With these theme creation options, keep in mind that for each theme on the site (even inactive ones), some records may be created in the wp_posts table.

Workflow

Now that we’ve seen all the plugin’s features, how would we work with it day to day? Let’s see.

Imagine your brother-in-law has a business with a hideous website, and you’re going to redesign it. First of all, we need to decide how we’re going to work:

  • Do we want to build a theme from scratch and are we able to keep that theme updated as WordPress receives updates in the future? In that case, our option is Create Blank Theme.
  • Is there a theme we really like that we want to modify as we please, and do we feel able to keep updating it in the future? In that case, our option is Create Theme > Clone Theme.
  • Do we have a theme we really like and want to change its design, but the thought of having to keep updating it makes us groan? In other words, we’re in the “you do it, I can’t be bothered” camp. In that case, the option to choose is Create Theme > Create Child Theme.

Right, we’ve made that all-important decision. We get down to designing and making changes to the theme. For example, we’ve added a font that didn’t come with the theme, changed the template designs, chosen a different global style from the one we were using, even modified a new design pattern…

We need to remember that all of this is saved in the database, but we want to be able to hand our new theme over to our brother-in-law, whose website is truly awful. So we’ll need to consolidate those changes into the theme. To do this, we use the Save Changes to theme option, saving all the changes as template files, the specific design changes in the theme.json file, and even the sample images we’ve added to the patterns we created, for example.

On top of that, our brother-in-law has terrible brand colors that don’t match any of the combinations the clever WordPress folks, or the creator of the theme we started from, have included among the many styles that usually come with it. So we’ve had to combine colors following aesthetic guidelines of questionable taste. We also need to change the text spacing, link colors and so on.

We’ll do all of this, but since we know it’s saved in the database, to consolidate it and finish perpetrating our theme, we’ll save it with Save Changes to theme. And all of this will be saved in a .json file with whatever name we want, inside the styles folder of the theme’s folder.

We’re done, we’re proud (or maybe not so much) of our creation, and we want to share it with the world. First, make sure you fill in the metadata with the title, description, author, even the website, etc., by clicking Edit Theme Metadata. If you like, you can review theme.json in case you want to check something specific, using the View theme.json option, and finally you can export the theme with Export Zip.

If it’s a completely original theme or a clone of another theme, you can hand it straight to your brother-in-law without any problem. He’ll install it and, more or less, everything will match your design.

If your theme is based on a parent theme and is a child of it, remind your brother-in-law that he must install the parent theme first, because otherwise he’ll call you within 30 seconds to tell you your theme is rubbish and doesn’t work.

Conclusions

As you’ve seen, this plugin is wonderful and gives us incredible freedom when designing, without depending on any proprietary theme. What’s more, if you’re a designer, here’s a possible way to make money, for example by creating child themes for a well-known theme: Powder is a good option, as is Twenty Twenty-Four itself, which is free.

Or, if you have more development skills, you can clone a theme and change it until it’s unrecognizable, or start completely from scratch and create your own themes, supporting them and uploading them to the theme directory if you wish.

As for me, my preferred option is to choose a theme whose base I like, create a child theme and adapt it completely to what I need.

Here’s a table summarizing what each option involves.

OptionType of optionWhat does it do?
Save Changes to ThemeConsolidating changesSaves the changes we’ve made to the design, block patterns, added fonts, etc. in the theme folder. It usually saves the templates (.html), the theme.json file with certain styles, and any /assets we’ve added.
Create Theme VariationConsolidating changesSaves any new styles we’ve created as a .json file in the /styles folder.
Edit Theme MetadataCross-cutting optionsWith this option we can add the theme credits and edit its metadata.
View theme.jsonCross-cutting optionsHere we can check the changes happening in theme.json as they happen.
Export ZipCross-cutting optionsExports the theme to a .zip file.
Create Blank ThemeTheme creationCreates a completely new blank theme, with no styles.
Create Theme > Clone ThemeTheme creationClones the active theme into a new folder; it will no longer receive updates when the original theme does.
Create Theme > Create Child ThemeTheme creationCreates a child theme from the active theme; if the parent theme receives updates, we won’t lose any of the changes we’ve added.
Summary table of the different options of the Create Block Theme plugin

I hope this post helps you understand this very interesting option you can now add to WordPress.

Just keep in mind that it’s under development and isn’t recommended for production sites. It’s better to have a development site, which can be a clone of the production site, and make all the changes you want there to the new theme or child theme you’re creating.

Jesús Yesares Avatar

Leave a Reply

Your email address will not be published. Required fields are marked *