How to call static block in magento2

Home / Magento2 / How to call static block in magento2

Creating static block Magento2

=> Login in into your magento2 development admin panel.
=> Navigate to Content->Blocks
=> Click Add New Block
=> Give your block title (Title: A descriptive name to identify this block)
=> Give your block identifier (Identifier: The identifier will allow you to call this block from your template files or using the Magento markup tags. Typically this would be a programmer-friendly name with no spaces or punctuation ie “my_block_identifier” rather than “My block’s identifier!”)
=> Set status enabled (Status: Here you can enable or disable a block.)
=> Enter your block content field (Content: As well as standard HTML you can also include special Magento markup tags in the block content. You can find information about these tags on the markup tags wiki page.)
=> Click Save Block or Save and Continue Edit to save your settings.

How to call image in static block

{{media url="wysiwyg/exclusive-icon.jpg"}}

How to create a link to another page within your site

{{config path="web/unsecure/base_url"}}

How to call static block any XML file

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

How to call static block in your template or .phtml files

<?php echo $this->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('block_identifier')->toHtml();?>

How to call static block in CMS->Pages

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

Related Posts


  • Magento developers many times get confused for designing a website in a unique way. After visiting this article, one can easily get the overview of designing a particular Ecommerce website. As the matter of fact, various platforms require different kinds of designs for better engagement of a product. So after visiting here, one can easily get the best overview of designing a website.

  • Heya! I just wanted to ask if you ever have any problems with hackers?
    My last blog (wordpress) was hacked and I ended up losing many months of hard
    work due to no data backup. Do you have any solutions to
    stop hackers?

  • Hello! I know this is kinda off topic but I was wondering which blog platform are you using
    for this website? I’m getting fed up of WordPress because I’ve had issues with hackers and I’m looking at options for another platform.
    I would be awesome if you could point me in the direction of a good platform.

Leave a Reply

Your email address will not be published. Required fields are marked *