3 Easy Methods to Call CMS Static Block in Magento 2


CMS blocks are vital assets of Magento 2. Using CMS blocks, you can display text, images, videos, and other static content anywhere on Magento 2 site. Not only static content but you can also add dynamic content using widgets in static blocks.

You do not need to write any code to add the contents. Magento 2 CMS blocks provide WYSIWYG Editor which is very easy to use. Using this editor you can style your text and insert the images easily. In case you have already created a static block, you might be looking for how to call cms static block in other Pages and files.

In this post we will see how to call CMS static block in CMS page, layout XML file and PHTML file.

Call CMS Static Block in CMS Page

If you are creating a static page and want to call some blocks on that page, you can use the below code on your page. You have to replace your block identifier in the block_id parameter.

{{block class="Magento\Cms\Block\Block" block_id="block_identifier"}}

Call CMS Static Block in Layout XML File

Sometimes while developing custom module, you need to insert CMS block inside your XML layout file. To call CMS static block in layout XML file you can use below code. You have to replace your block identifier in block_id parameter.

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

Call CMS Static Block in PHTML File

If above two methods are not feasible and you need to call CMS block in PHTML file, you can use below code. Replace setBlockId argument with your block identifier.

<?= $this->getLayout()


As per your requirement, you can call a static block in CMS pages, XML layout files, and PHTML files. Got question? Feel free to ask in the comment box below.

Want to ask a question or leave a comment?

Leave a Comment


All the comments are goes into moderation before approval. Irrelevant comment with links directly goes to spam. Your email address will not be published.

Was this post helpful? Please support Us!

Follow us on twitter or Like us on facebook.


To Avoid Spam Downloads, We Want Your Email

We will send you download link right
away. Please submit form below.

Increase Your
Magento 2

Get Weekly Tutorial
to your Inbox
Subscribe Me
Subscribe Here