0

I'm using Gutenberg and various custom content types like blog post, person, article, etc. I want it so when a user creates an article it automatically fills the page with a preset set of blocks with placeholder data, or data that came from custom fields for that content type.

I do see that there's a page template section https://www.drupal.org/docs/8/modules/gutenberg/page-templates that you can set for each content type. But instead of manually writing the JSON for the template I want to be able to take the content I've already entered and export it to JSON so I can paste it into that field.

Is it possible to export content from the Gutenberg visual editor to JSON so I can use it as a template for content types?

Update: I do see that content from gutenberg is stored in the database like so

<!-- wp:html -->
<p>This is the body text for node three</p>
<!-- /wp:html -->

<!-- wp:columns -->
<div class="wp-block-columns"><!-- wp:column -->
<div class="wp-block-column"><!-- wp:heading -->
<h2>asdf</h2>
<!-- /wp:heading --></div>
<!-- /wp:column -->

<!-- wp:column -->
<div class="wp-block-column"><!-- wp:heading -->
<h2>Test</h2>
<!-- /wp:heading --></div>
<!-- /wp:column -->

<!-- wp:column -->
<div class="wp-block-column"><!-- wp:heading -->
<h2>Test</h2>
<!-- /wp:heading --></div>
<!-- /wp:column --></div>
<!-- /wp:columns -->

But I'm not sure how to turn that into a useable format for the page template.

1
  • A bit of a late reply here, but the Drupal Gutenberg team is working on an improved way of defining a Gutenberg layout template for content types (so you don't need to type your own JSON). Not sure when it will be released, but it is in the pipeline. – thorandre Feb 5 at 8:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.