Call CMS Block in Magento 2 Using Layout XML

 Although Magento 2 CMS blocks are managed directly from Magento admin using widgets and WYSWYG editor you can add them other ways too.

If you have some technical skills you can just call CMS block in Magento using the XML file.

Call CMS Block Using XML File

Use the following code to add CMS blocks using Magento 2 layout XML:

<referenceContainer name="content">
  <block class="Magento\Cms\Block\Block" name="unick_block_name">
    <arguments>
      <argument name="block_id" xsi:type="string">my_cmsblock_identifier</argument>
    </arguments>
  </block>
</referenceContainer>

You need to replace "my_cmsblock_identifier" with your CMS block Identifier or ID (we recommend using Identifier). 

Display CMS Blocks Dynamically (by Date)

Even if you add CMS blocks programmatically using the XML file, they will still be static. It means that you'll need to replace the identifier or disable a block manually. But not if you use the Magento 2 Dynamic Blocks.

This way, you can display your CMS blocks dynamically, by different dates, times and days of the week.

magento dynamic blocks date

But that's not it. You can also show unique blocks for each customer group, while you insert only one block into the XML file.

And if you just want to explore other ways to insert CMS blocks in Magento, try calling CMS block in the PHTML file.