Gutenberg

for Site Developers

(use spacebar or swipe to proceed)

Hi!

· Michael Dance

· Live in DC

· WordPress developer at CHIEF

The Old

Classic editor view
View of edit screen with custom fields

The New

The Problem

Clients need handholding

Computer says Press Any Key, Homer Simpson wonders where the Any key is

You want them to make this

Well-designed blog post

But they end up making this

Ugly blog post with many bad design choices

How to use Gutenberg sensibly?

What Gutenberg is Good for

  • Unstructured content
  • Long-form articles
  • Media

What Gutenberg is Not Good for

  • Heavily structured content
  • Layout building
  • Simplification

What Options Do We Have?

  • Classic Editor plugin
  • Custom fields (with Gutenberg or Classic)
  • Removing Gutenberg on certain post types


	remove_post_type_support( 'post', 'editor' );

						


	'supports' => array( 'title', 'editor' )

						

A Reasonable Plan

Part 1: Sites

  • Maintenance sites: install Classic Editor
  • New sites: try Gutenberg
    ...but only use it on post types that make sense

Part 2: Post Types

  • Posts:
  • Pages:
  • Custom post types:
Wireframe of a basic post

Part 2: Post Types

  • Posts: use it
  • Pages:
  • Custom post types:
Wireframe of a basic landing page

Part 2: Post Types

  • Posts: use it
  • Pages: (maybe) use it
  • Custom post types:
Wireframe of an attorney bio page

Part 2: Post Types

  • Posts: use it
  • Pages: (maybe) use it
  • Custom post types: (probably) ditch it

Making a Gutenberg-Ready Theme

Limit Color Options



	// replace default colors
	add_theme_support( 'editor-color-palette', array(
		array(
			'name' => 'Light Gray',
			'slug' => 'light-gray',
			'color' => '#dedede',
		),
	) );

	// remove color picker
	add_theme_support( 'disable-custom-colors' );

						
Default
Default Gutenberg paragraph color options
Custom
Custom paragraph color options

Limiting Font Size Options



	add_theme_support( 'editor-font-sizes', array(
		array(
			'name' => 'Regular',
			'slug' => 'regular',
			'size' => 16,
		),
	) );

						

"Themes are responsible for creating the classes"

https://gist.github.com/mikedance/
ba2bb268570bd7cf22b258e88bb0af94

Wide & Full Alignments



	add_theme_support( 'align-wide' );

						

Editor CSS



	add_editor_style(); // load
	add_theme_support( 'editor-styles' ); // namespace

						

Recommended reading:

https://wordpress.org/gutenberg/
handbook/extensibility/theme-support/

Block Templates



	register_post_type( 'resource', array(
		'label'         => 'Resources',
		'public'        => true,
		'supports'      => array( 'title', 'editor' ),
		'show_in_rest'  => true,
		'template'      => array( /* next slide */ ),
		'template_lock' => 'all', // or 'insert'
	) );

						


	array( 'core/heading', array(
		'content' => 'Description',
	) ),
	array( 'core/paragraph', array(
		'placeholder' => 'Enter description...',
	) ),
	array( 'core/separator', array(
		'className' => 'is-style-wide',
	) ),
	array( 'core/heading', array(
		'level' => 3,
		'content' => 'Download',
	) ),
	array( 'core/file', array() ),

						
Gutenberg screen pre-loaded with blocks specified by the Resource template

Considerations

  • You can only template what's available
    • No single-line text block
    • No locked HTML labels
  • Nested blocks need work
  • Template functionality will expand

Final Tips

For a project in flux,
Source Code > Documentation
Learn how to create custom blocks
Expect things to take longer at first
We can drive Gutenberg's evolution
Questions?