Blog Menu

I write and curate content for Bluehost. I hope this blog post is helpful.
Are you looking at creating a blog, website or an online store? Bluehost has something for everyone. Get started today.

The Gutenberg block editor, WordPress’ content editor, has over 81 million active installations. Because of the market-dominating nature of WordPress and the intuitive nature of this editor’s design, it’s no surprise that this system is so popular.

Gutenberg is an accessible drag-and-drop page builder and content editor. It offers many functionalities, along with varied approaches you can use to create the curated website of your dreams.

This editor is built on Gutenberg blocks, diverse units of content that make up a website’s pages and layout.

You can get these blocks from the WordPress Block Library. This library is extensive, but it doesn’t always have the exact block you need for your website.

So, if you’re an entrepreneur who wants advanced website functionality or specialized elements not yet offered by Gutenberg, you might be interested in using Gutenberg custom blocks on your WordPress website.

Gutenberg: WordPress’ core content editor

WordPress Gutenberg content editor.
Screenshot

The Gutenberg editor is the core of WordPress’ content editing framework. Its block-based structure makes it easy to build a WordPress website and all of its pages — even for total beginners.

With this editor, you can create media-rich content in WordPress by choosing the new blocks you need. Then, you can size them as you wish and add the specific elements you want to appear on each page.

What are Gutenberg blocks?

Gutenberg blocks are the elements that make up a page or post.
Screenshot

In Gutenberg, every page or post is made up of a collection of self-contained elements.

You use these elements — or blocks — to construct pages, posts and everything else on your WordPress website.

The most popular block is the paragraph block, followed by the image and heading blocks. Other examples of block types include titles, text, dividers, widgets and videos.

As we mentioned earlier, you can access WP blocks through the Block Library. You can find this by clicking the + on the top-left side of your WordPress toolbar while editing a page or post.

But what if WordPress’ library doesn’t offer the block type you’re looking for? Or any placeholder that you might be able to upgrade to suit your needs?

That’s where custom blocks come in.

What are Gutenberg custom blocks?

Gutenberg allows anyone to create free assets. So if you have coding and web development experience, you can build custom blocks while creating your website.

Custom blocks offer even more flexibility and niche-specific functionality than default blocks.

Users build custom blocks to create unique page elements.

Gutenberg custom blocks offer many benefits, including:

  • You can design visually appealing, media-rich WordPress elements curated to your business’s needs.
  • They add unique and advanced functionalities to your website.
  • They enhance the aesthetic look of your pages and help your business stand out from the crowd.
  • You only need to code blocks once. After that, you can use them across all of your websites and pages.

However, custom blocks come with some challenges. For one thing,making them requires in-depth technical knowledge. Also, you’ll need some specific coding expertise and developer tools.

How to get custom Gutenberg blocks for WordPress

How to get custom Gutenberg blocks for WordPress.

To get Gutenberg custom blocks, you have to either build them yourself or purchase them.

Creating custom blocks isn’t in everyone’s skill set, but that isn’t a problem. You can buy custom Gutenberg blocks instead of building them yourself. To do so, find a top-notch developer you trust, then work with them to create your ideal blocks.

If you plan to create these blocks yourself, there are some things you should consider before you begin.

What to consider before creating custom blocks

Creating a Gutenberg custom block takes time and energy. Before you start the process, you should ensure you’ve exhausted all your other options.

You can verify that there aren’t any other suitable approaches by looking carefully through the library of Gutenberg default blocks. Make sure there aren’t any existing blocks that provide the basic functions or style specs you need.

And if you’ve determined that you do need a custom block, outline the vital specs for your block before you start building. Think about aesthetic elements, default settings and core features. Also, consider toolbar specifications and other key stylistic and functional characteristics.

What you need to build Gutenberg custom blocks

Once you determine your block’s most essential aspects, there are a few more key requirements you’ll need to fulfill prior to starting the process.

An active WordPress website is essential. And you’ll need at least some experience with JavaScript and JavaScript build tools, such as Node.js.

You will also need intermediate HTML, CSS and PHP knowledge to create your own custom blocks.

If you aren’t super well-versed in this area, no worries. You can save time and stress by hiring web design experts to help you build blocks instead.

How to create custom Gutenberg blocks in WordPress

There are two accessible approaches to building Gutenberg custom blocks. You can either install a user-friendly plugin that simplifies the process or build them from scratch using HTML/CSS or PHP code.

How to create custom Gutenberg blocks in WordPress

Creating custom blocks with a plugin

There are a number of block-building WordPress plugins available that streamline the process of creating Gutenberg custom blocks for your WordPress site. We recommend using Genesis Custom Blocks.

To create your first block with this plugin:

1. Install Genesis Custom Blocks

Install the Genesis Custom Blocks WordPress plugin.
Screenshot

First, navigate to Plugins > Add New in your admin dashboard’s left sidebar and search for Genesis in the WordPress Plugins Directory. Install it and click the Activate button.

2. Create a new block

Go to Custom Blocks > Add New in your WordPress dashboard.
Screenshot

Next, navigate to Custom Blocks > Add New to create a block.

3. Configure block specifics

Configuring the block.
Screenshot

Now, you can select a block name, then configure and customize its properties. To help with search engine optimization (SEO), add relevant keywords.

Then, add fields — such as numbers, images and checkboxes — by pushing the + button. You’ll need to input more specs, such as Field Label, Field Location and Help Text. You can reorder, edit and delete fields, as well.

4. Build your template.

Building a template.
Screenshot

Next, you can build your template with either HTML and CSS or PHP, depending on your block output.

If your block is configured for HTML and CSS, you can use the plugin’s Template Editor, found on the top bar. There, you can customize your block via the Markup (HTML) and CSS tabs.

And if you want to add PHP, you’ll need to use a plain text editor to create block.php and block.css files manually.

5. Save and confirm your block

Make sure to save your block by clicking Publish in the top right.

6. Add your block to your website

Adding the block to a page.
Screenshot

Finally, you can add the block to your website. Open or create a post or page, then press the + on the left sidebar of your dashboard to find and embed your block.

Then, customize the page content to your heart’s desire with other blocks, useful WordPress shortcodes and other accessible approaches that optimize user experience (UX) and website performance.

Creating custom blocks manually

Alternatively, you can code Gutenberg custom blocks from scratch by following this step-by-step process:

1. Set up your WordPress developer environment

You’ll need to include Node.js in your WordPress developer environment.
Screenshot

First and foremost, install Node.js and the Node package manager (npm). These are JavaScript build tools that allow you to define basic block functions. You can download Node.js via the online installer and then ensure the npm is activated by inputting the command npm-v in your code editor.

Next, you’ll need to install Docker, a requirement for using WordPress’ developer tool. The Docker website offers simple one-click installation.

After that, you’ll set up your developer environment and activate your staging site. You can set up the dev environment through WordPress’ default tool. Install it globally by inputting the command npm -g install @wordpress/env.

2. Set up your base (starter) plugin file

Before you can actually create your Gutenberg custom block, you have to create a base block plugin for reference. Thankfully, there are a few approaches that help you avoid manually completing this step.

Run the command /wp-content/plugins/ to navigate to your plugin directory.

Then, one option is to run the command npx @wordpress/create-block.This gives you easy access and editing capabilities for your PHP files and JS files.

Make sure you add the name you want to use for your starter block to the command. You can use something simple, like my-new-block, or be creative.

Your other option is to install the create-guten-block tool and run the command npx create-guten-block with the name of your starter block.

You can use the create-guten-block tool to set up your starter plugin file.
Screenshot

These processes will create a jumping-off point.

3. Configure block.json

You should add a block.json file to your new directory, then configure it by inputting metadata and selections for various settings. Examples of settings include block attributes and other adjustable specs, like the application planning interface (API) version, title and category.

Here is an example of what part of the block.json code could look like:

You need to configure your block.json file’s settings, including the API version.
Screenshot

The block.json file allows your basic block plugin to show up in the plugins directory, makes registering your block easier later on and helps with your website’s performance.

4. Configure more specs

Next, you’ll determine and enqueue specifics regarding:

  • Styles.
  • Dependencies and asset files.
  • Attributes.
  • Scripts.
  • Labels and keywords.

You can navigate to the package.json file to configure your JavaScript properties, styles and scripts. Through block.json, you can define attributes with the setAttributes function. You can also alter block settings with labels and keywords.

You can add other frontend and backend specs and edit various functions. For example, you should create an asset file to add dependencies. You can do this by inputting the command npm run build for your JavaScript XML (JSX) file or the following PHP code:

PHP code to create an asset file for your dependencies.
Screenshot

5. Register your block

Once you create your block plugin, use the function register_block_type. This block registration technique automatically pulls the previously determined metadata from the block.json file.

6. Save and confirm your block works

The final step is to save all the files and test your new block.

You can confirm its functionality by adding your new Gutenberg custom block to your website. If you insert it and it shows the “Hello World” message, that’s a sign you completed the process correctly.

If you want to use the same block in multiple layouts or websites in the future, try using it in a Gutenberg block pattern.

Browse the WordPress “Learn” page for more specifics and tutorials on how to configure your website.

Final thoughts: How to create Gutenberg custom blocks — a Bluehost guide

Making Gutenberg custom blocks for WordPress is a useful solution if you need website elements not offered by any default blocks.

You create your own Gutenberg blocks with a plugin or through manual coding. However, either process requires some technical expertise.

If you don’t want to make custom blocks yourself, try Bluehost’s Website Design services. Our team of committed experts is here to help you customize and cultivate the perfect website.

If you want to design your website yourself but would like some expert site editing guidance along the way, we also offer Pro Design with live support. Our experts can help you choose and customize the perfect themes and plugins and optimize your website.

Then, once your website is ready to go live, contact us at Bluehost to get high-speed, high-quality and high-performance WordPress hosting services.

  • Minal Agarwal

    Minal is the Director of Brand Marketing at Bluehost. With over 15 years of business experience in the technology industry, she strives to create solutions and content that fulfill a customer's needs. She is a dog mom and a stickler for calendaring.

    Education
    Masters in Marketing Management
    Previous Experience
    Strategic Partnerships, Customer Success, Events and Community
Learn more about Bluehost Editorial Guidelines

Write A Comment