Create Pages using Gutenberg (WordPress Editor) in Drupal 8
Tags: drupal, gutenberg, wordpress
Published: 2019-08-09 06:29:51

{% youtube xlH9LLLTzF8 %}

_Get notified when new tutorials are published. [Subscribe to our newsletter](https://www.webwash.net/newsletter/)._

**📽 Video sections:**

*   Download and Install Gutenberg ([01:15](https://www.youtube.com/watch?v=xlH9LLLTzF8&t=75s))
*   Configure Gutenberg on Page content type ([02:01](https://www.youtube.com/watch?v=xlH9LLLTzF8&t=121s))
*   How to use Gutenberg editor ([03:21](https://www.youtube.com/watch?v=xlH9LLLTzF8&t=201s))
*   Upload images into Gutenberg ([06:55](https://www.youtube.com/watch?v=xlH9LLLTzF8&t=415s))
*   Create reuseable blocks ([11:02](https://www.youtube.com/watch?v=xlH9LLLTzF8&t=662s))
*   Use Gutenberg Cloud ([15:42](https://www.youtube.com/watch?v=xlH9LLLTzF8&t=942s))
*   Learn how the Gutenberg data is stored in Drupal ([20:31](https://www.youtube.com/watch?v=xlH9LLLTzF8&t=1231s))

> Want to Learn Drupal? [Check out our FREE courses](https://www.webwash.net/product-category/courses/).

[Gutenberg](https://github.com/WordPress/gutenberg) is the new editor for WordPress 5.0. It's a new style of editor/page builder. Instead of writing text in a single text area, you build a page using blocks. A block could be something simple such as a paragraph or an image. Or more complex blocks like a "Media & Text" or adding in columns. 

The editor itself is written in Javascript, more specifically React. This is what makes it possible to be used in Drupal. But I'm sure extra works was required to get it working in Drupal. 

In this tutorial, you'll learn to install and configure the [Gutenberg](https://www.drupal.org/project/gutenberg) module, and you'll learn how to use it on the Page content type. 

If you're keen to have a play with the editor without configuring a Drupal site go to [https://drupalgutenberg.org/demo](https://drupalgutenberg.org/demo).

## Getting Started

Before we begin, go download and install the Gutenberg module. Run the following Composer command:

<pre>composer require drupal/gutenberg</pre>

Once you've downloaded the module go to Extend and install it. ![](https://thepracticaldev.s3.amazonaws.com/i/uy6rhbbfyllc0rykewwf.jpeg) 

## Configure Gutenberg on Page Content Type

Now that we've installed the module let's configure it on the Page content type. 

1\. Go to Structure, "Content types" and click on Edit from the Operations menu. ![](https://thepracticaldev.s3.amazonaws.com/i/4e2ig90o9799kjjh3o4n.jpeg) 

2\. Click on "Gutenberg experience" from the vertical tabs and check "Enable Gutenberg experience". 
![](https://thepracticaldev.s3.amazonaws.com/i/wuyguoh1f2jy59s6z2sx.jpeg)

3\. Click on "Allowed blocks" to expand a list of available blocks. You can control which blocks will be available for editors to use. 

![](https://thepracticaldev.s3.amazonaws.com/i/6516jpxvhb6bsujfn1ci.jpeg)

4\. Once you've configured everything, click on "Save content type". 

That's all the setup work required to get it working on any content type, pretty easy.

## How to use Gutenberg

Now go to Content, "Add content" and click on "Basic page". You should now see a very different node edit form.

![](https://thepracticaldev.s3.amazonaws.com/i/c47spv2bfvqw1f3lbw72.jpeg)

### How to Add Content

The Gutenberg editor is very different than the text editor which comes with Drupal 8\. Instead of just writing into a large text field, you create and manage blocks (Gutenberg blocks).

**NOTE: I'm not referring to Drupal blocks which are added to regions.** 

To see all the available blocks, hover over "Start writing or type.." or click on the plus (+) icon. 

![](https://thepracticaldev.s3.amazonaws.com/i/3cdmdi0adpgpdj9ti2ve.gif) 

Let's say, for example, you want to add a heading and a paragraph. You would create a Heading block, then a Paragraph block. 

![](https://thepracticaldev.s3.amazonaws.com/i/dos63int7tok9bojce58.gif) 

Instead of clicking the (+) icon, you can add blocks even quicker by typing "/" and search using its name. Any block can be added this way. 

![](https://thepracticaldev.s3.amazonaws.com/i/da4hkno51ima4ttpdcwi.jpeg) 

Also, if you paste in a bunch of text then the Paragraph block will be automatically used.

### Block Configuration

Each block has its own configuration. If we take the Paragraph block, for example, you can change the font-size, background color, text color and more. You can access the settings by clicking on the Block tab on the right. 

![](https://thepracticaldev.s3.amazonaws.com/i/0duw81f0wtasnp3n37oj.gif)  

## Integration with Drupal's Managed File System

Apart from just offering the editor, the Gutenberg module integrates nicely with Drupal's managed file system. 

Take for example the "Media & Text" block. You can upload files (by drag-and-drop as well, which is great) and add text to the right. 

![](https://thepracticaldev.s3.amazonaws.com/i/4unz3sv3iw750ig61srt.gif)

And if you click on "Media Library" you can reuse any images which have already been uploaded.

![](https://thepracticaldev.s3.amazonaws.com/i/dhe5n6pxd706698t3z7x.jpeg)

## Add Drupal Blocks into the Editor

You can add Drupal blocks into the editor (now I'm talking about Drupal blocks which are added to regions). 

Just search for any block using its name or look in the "Drupal Blocks" section. 

![](https://thepracticaldev.s3.amazonaws.com/i/as9u2ov2s3pqnne81llc.jpeg)

Here's an example of how to add the "Recent content" block view.

![](https://thepracticaldev.s3.amazonaws.com/i/qonxfhx7wuwxndjkwlod.gif)

There are a lot of different blocks in Gutenberg, and I recommend you spend time playing around and learning how to use them.

## Create Reusable Blocks

Gutenberg allows you to create reusable blocks. These blocks can be added to any page and if you modify the block, it'll change across all pages. 

For example, let's create a List block which will be reused on multiple pages. 

1\. Create the block in Gutenberg. 

2\. Click on the 3 vertical dots which will open the "More options" drop-down. 

3\. Then click on "Add to Reusable Blocks". 

![](https://thepracticaldev.s3.amazonaws.com/i/1ocf4i2h7vhycw8ewfjw.gif)

### Add Reusable Block to Page

To reuse a block, click on the (+) and you should see a Reusable section with the block. 

![](https://thepracticaldev.s3.amazonaws.com/i/4ub9eykc877pfu1qbql2.gif)

To edit a reusable block, add it to a page and click on the Edit button. 

![](https://thepracticaldev.s3.amazonaws.com/i/cthlkeybthf5hzjynedx.jpeg) 

NOTE: This will change the block across all pages which are using it.

## Managing Custom Fields

You may have noticed that the editor takes over the whole node edit page. What happens if you use Gutenberg on a content type with custom fields? 

The fields get added at the bottom of the page in a field-set called "More settings": 

![](https://thepracticaldev.s3.amazonaws.com/i/k8yw8aqn3djgr6v44xdn.jpeg)

## Gutenberg Cloud

The team who built the Gutenberg module also created a website called [Gutenberg Cloud](https://gutenbergcloud.org/). It allows you to share Gutenberg blocks with others. 

![](https://thepracticaldev.s3.amazonaws.com/i/j1ej9yb3p8doac293pc1.jpeg) 

Using blocks in your own site is easy. You just need to enable the "Gutenberg Cloud" sub-module which ships with the module.

1\. Go to Extend and enable "Gutenberg Cloud". 
![](https://thepracticaldev.s3.amazonaws.com/i/617w3ddc4he4q7ciqihv.jpeg) 

2\. Then, go to Configuration, "Gutenberg Cloud block manager".

![](https://thepracticaldev.s3.amazonaws.com/i/gfram10qwtnh6ywiks18.jpeg) 

From this page, you can enable blocks from "Gutenberg Cloud" to be used on your own site. 

When you enable a block nothing is downloaded into the site. Gutenberg blocks are written in React so it's just JavaScript. The code for the block is served via a CDN. 

3\. To use enabled blocks, just select them from the "Cloud Blocks" section. Or search for them by name. 

![](https://thepracticaldev.s3.amazonaws.com/i/hp3yv0pws09c4h8tuko3.gif)

## How is the Gutenberg Data Stored?

So you may be thinking right now; how is the data stored in Drupal? When you add a block, where is it stored? 

Short answer, it's stored in the body field. 

If you look in the `node__body` table and look in the `body_value` column you'll see that all the blocks are stored as markup. 

![](https://thepracticaldev.s3.amazonaws.com/i/2sf31rxbpiqydi7f26vl.jpeg)

## Summary

Setting up the Gutenberg editor was easy. By simply checking the "Enable Gutenberg experience" checkbox on a content type, you have the editor up and running. To be honest, I was surprised it was this easy to configure.

_Originally published at [WebWash](https://www.webwash.net/?p=8697) on April 4, 2019._