Using Block Templates with Gutenberg – Bill Erickson


Block templates are one of my favorite new features in Gutenberg. You can specify a list of blocks that automatically appear in the content editor, and you can customize what appears in each block by default. You can also lock the template so no additional blocks can be added. This is a great replacement for metaboxes in many cases. You can control the content structure without sacrificing the visual editing experience.
Block templates are currently set for an entire post type, but you will soon have more granular control to define them in page templates and other contexts.
Here’s a few examples from a website I’m working on right now.
Post template with ads
Our client is a publisher who needs at least two ads in each post. There’s a few approaches we’ve used in the past:
Automatic insertion after X paragraphs. It’s simple to maintain but the ads often don’t follow the natural breaks in article.
Manual insertion using a shortcode. The content editor can ensure the ads work well with the content, but it’s more difficult to manage and easy to forget.
With Gutenberg, we simply pre-populate the content area with two ad blocks (built with Advanced
Source: https://managewp.org/articles/18214/using-block-templates-with-gutenberg-bill-erickson



source https://williechiu40.wordpress.com/2018/12/15/using-block-templates-with-gutenberg-bill-erickson/