Gutenberg Full Site Editing and Block-Based Themes
### Note Right now block-based themes and full site editing are still work in progress. I write about it because, sooner rather than later, themes will take advantage of full site editing and they will become a new tool in the arsenal for WordPress developers. These features are not part of Core WordPress, they require the latest Gutenberg plugin (not the version that is bundled with WordPress), and the APIs discussed in this post may change before they are merged into core and become official parts of WordPress. An experimental feature available in recent versions of Gutenberg is the ability to [create block-based themes](https://developer.wordpress.org/block-editor/how-to-guides/block-based-theme/) The idea is that themes will leverage blocks, patterns and other Gutenberg features to enable easier development and customization of a theme. A related feature, also under development, is [Full site editing](https://wpengine.com/blog/full-site-editing-future-of-building-with-wordpress/) (`fse`). According to the [fse page](https://make.wordpress.org/design/handbook/focuses/full-site-editing/) in the WordPress Design Handbook: > The goal of the full site editing project is to utilize the power of Gutenberg’s block model in an editing experience beyond post or page content. In other words, the idea is to make the entire site customizable. This editing mode will understand the structure of the site and provide ways to modify global elements like headers and footers. In the current model, different parts of the ecosystem provide different functionality: themes provide the logical structure of a site, plugins extend the functionality of the site and the editor (classic or Gutenberg) allow you to create content for the site within the boundaries of the theme and with the functionality provided by the core WordPress and plugins. With `fse` things change. We now can use blocks to create other types of content like headers, footers, and sidebars. With these changes, the way we create themes also changes. In this post, I will talk about block-based themes and full site editing, how it works now, and what we can expect in the future ## Basic Requirements A block-based theme requires an `index.php` file, an `index template file`, a `style.css` file, and a `functions.php` file. The theme may optionally include an [experimental-theme.json](https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-json/) file to manage global styles. The basic requirement to edit a block theme is to have a theme that is already configured to work with blocks. For these examples, I generated an empty theme with the [block theme generator](https://github.com/WordPress/theme-experiments#generating-your-own-starter-theme). I then copied the `experimental-theme.json` styles from the[tt1-block theme](https://github.com/WordPress/theme-experiments/tree/master/tt1-blocks) to make sure that the styles work while I research the new syntax and whether that's absolutely necessary or I can still work with CSS on a global CSS file. ## Templates and template parts Block-based themes replace templates written in PHP and HTML with HTML files that contain HTML and Gutenberg markup. Templates are placed inside the `block-templates` folder, and template parts go in the `block-template-parts` folder: ```text theme |__ style.css |__ functions.php |__ index.php |__ experimental-theme.json |__ block-templates |__ index.html |__ single.html |__ archive.html |__ ... |__ block-template-parts |__ header.html |__ footer.html |__ sidebar.html ``` Each template is made of the raw markup for one or more blocks and HTML. To create the raw HTML blocks you need to either learn their syntax or copy them from the editor. In the following example, the comments containing `wp:` indicate the opening and closing instruction for a Gutenberg block. The following example has three elements - A `columns` container that will hold the child column elements and their content - Two `column` (singular) elements for each content and its column - The column on the left has an embed element for Youtube content - The column on the right has a paragraph ```html
The idea is to have text and a video