Skip to content
NewRedesigned blogFeedback
Jigar Karangiya

How to Call a Static Block in XML in Magento 2

Learn how to easily call a static block in XML in Magento 2! This guide walks you through adding custom content, such as banners and announcements, to specific areas of your store layout.

How to Call a Static Block in XML in Magento 2
Written by
JKJigar Karangiya
Published
Reading time
2 min read

Jigar Karangiya · · 2 min read

Static blocks in Magento 2 allow store owners to create reusable content, such as banners, promotional messages, and custom HTML, and place them in various locations across their site. For developers, knowing how to call a static block in XML is essential for better content management and improved store customization. This guide shows you the steps to quickly add a static block to specific layout areas using XML in Magento 2.

What is a Static Block?

In Magento 2, a static block (opens in new tab) is a pre-configured block of content managed via the admin panel. Once created, it can be called directly in XML layout files, making it ideal for placing custom content on specific pages or sections of your store.

Calling a Static Block in XML

To display a static block in Magento 2 using XML, follow these steps.

1) Identify the Block’s Container
Choose the area where you want to display the block, such as the main content area, header, or footer.

2) Use the XML Code

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

Replace "**content** " with the desired container (header, footer, etc.), and set "**your_block_identifier** " to match the unique identifier of the static block created in the admin.

3) Clear Cache
After updating the XML file, clear the Magento 2 cache to see the changes reflected on the front end.

Example: Adding a Static Block to the order success page

xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="order.success.additional.info">
            <block class="Magento\Cms\Block\Block" name="checkout-success-additional-info">
                <arguments>
                    <argument name="block_id" xsi:type="string">checkout-success-additional-info</argument>
                </arguments>
            </block>
        </referenceContainer>
    </body>
</page>

By using static blocks, you can easily manage promotional banners, announcements, and custom HTML without modifying your theme files every time. This approach saves time and makes content updates more flexible, especially for non-developers. Whether you’re customizing the footer, header, or main content area, following these steps will give you more control over the layout and appearance of your Magento 2 site.

Feel free to explore other ways to enhance your Magento 2 store by combining static blocks with dynamic content strategies.

Happy customizing!

P.S. Do share this note with your team.

(opens in new tab)

You may also like:

Magento 2: How to use helper in PHTML?

Magento 2: How to get a dynamic Base URL Path in XML?

How to remove/disable add to compare in Magento 2?

Keep reading
All posts

01 · 10 min · Shares Adobe Commerce Core

Adobe Commerce Agentic Capabilities, Q4 2026

Five agentic releases for Adobe Commerce: LLM product discovery, Brand Visibility, the Shopper MCP server, Brand Concierge, and Experience Workspace. What each one does, which editions get it, and when.

10 min

03 · 3 min · Shares Adobe Commerce Core

Conditions for Collections in Magento 2

Collections in Magento 2 (Now Adobe Commerce), are among the most powerful tools for retrieving and manipulating data directly from the database.

3 min

Newsletter

New Magento tutorials, straight to your inbox

Code examples, performance tips, and fixes for common Magento issues. No spam.

Subscribe