You have probably notices that CMI has some limitation in exporting custom blocks. These are unfortunately quite important for Front enders and also for client. Let me show you, how you can simply create custom blocks in code during installation of your module.
If you are reading this blog, I assume you know that blocks are finally entities in Drupal 8. You can define your own block type and add some fields into it. For simple demonstration I’m using predefined custom block type Basic block with body text field. Same approach can be of course used for your custom block types with many additional fiels.
First you need to create Custom block:
If you install your module now, you can find this block in Custom block library. You can update all fields which is big change since Drupal 7, but you still need to show your block somewhere on page. Because block are entities, they can be displayed multiple times. You need to create block instance which can be placed into region and visibility settings can be applied.
Now you just need to put this code into your module’s .install file and enable it. Enjoy :)