Gutenberg – How to update blocks and block-templates in bulk

At the time of writing, there is still no documented way to update blocks. So here is how I would update all my blocks:

  1. Loop trough all posts.
  2. Find patterns matching:
    <!-- your-block -->*<!-- /your-block -->
  3. Optional: convert the block to PHP Array with parse_blocks()
  4. Replace according to your new block
  5. Save post with the updated block

Obviously, step 4 is going to be the hardest part. What you will actually do here depends on how your new block looks.

Plugin: Bulk Update Blocks

I have started work on a plugin to update blocks.

Is there no standard way to do this?

For some time now, the Gutenberg core team seems unwilling to standardize this, while there is an obvious need for this functionality as you can see here.

I hope that by the time you read this, this post will have become obsolete because there is actually a better solution at that point. If you found a better way, please leave a comment.