How to add a cms static block to all pages in Magento?

How to add a cms static block to all pages in Magento?

September 3, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How to add a cms static block to all pages in Magento?

Adding a CMS Static Block to All Pages in Magento

Static blocks are powerful tools in Magento that allow you to insert reusable content into various parts of your website. Whether it’s a promotional message, important links, or additional information, static blocks provide a structured way to manage and display this content across multiple pages.

An Overview of Magento Static Blocks

At the core, a static block is simply a content container that can be inserted into any page layout using CMS layout handles. You define the content for each static block once in the admin interface, and then tell Magento where you want it to appear by assigning it to specific layout handles.

Static blocks are ideal for:

  • Adding consistent footers or headers across all pages
  • Displaying promotional banners on category and product pages
  • Showcasing important links or information

Creating a New Static Block in the Admin Interface

To create your first static block, log into your Magento admin panel and navigate to Content > Elements > Blocks.

  1. Click the “Add New Block” button.
  2. Enter a Block Title that describes the content (e.g., ‘Footer Links’).
  3. Choose the Store View where this block will be active.
  4. In the Content field, enter or paste the HTML or text you want to display in this static block.

For example, you might add your footer links like this:

<a href="https://laravelcompany.com">Home</a> | <a href="#">Contact Us</a>
  1. Click “Save Block” to create it.

Assigning the Static Block to Your Layout

Now that you have created your static block, you need to tell Magento where to insert it into your page layout. This is done using CMS layout handles and XML code.

For adding a static block just above the footer links on all pages (including home, category, etc.), you’ll use the before_body_end handle:

  1. In your admin panel, navigate to Content > Design > Layout XML.
  2. Find the Handle that corresponds to your store view’s layout (usually named after your theme).
  3. Under the Actions column for that layout, click “Edit”.
  4. Scroll down to find the before_body_end handle in the XML tree.

You can add your static block using this syntax:

<reference name="before_body_end">
    <block type="cms/block" before="-">
        <action method="setBlockId"><block_id>footer_links</block_id></action>
    </block>
</reference>

Replace footer_links with the actual Identifier of your static block.

  1. Click “Save Layout Update” to apply these changes.

Using PHP Code to Generate Static Blocks

If you need more dynamic content in your static blocks, Magento allows you to use PHP code within them using special {php} tags.

For example, if you want to display the current date and time:

<p>Today is {php $now = new Varien_Datetime(); echo $now->format('M d, Y H:i:s')}</p>

Best Practices for Using Magento Static Blocks

  • Keep your static blocks as modular as possible. This makes it easier to manage and update content across multiple pages.
  • Avoid adding too many static blocks to a single page. Excessive blocks can slow down your site’s loading times.
  • Regularly review and update your static block content to keep information current.

Conclusion

Static blocks are essential tools for managing reusable content in Magento. By following this guide, you now know how to create, assign, and even generate dynamic content using PHP within these blocks. This will allow you to maintain consistency across your website while keeping your code clean and separated from page layout files.

Remember, the key to effective use of static blocks is keeping them modular and strategically placed based on your specific business needs. With practice, you’ll find that static blocks become one of your most powerful tools for managing content in Magento.

Happy coding! If you have any further questions or need more advanced help with your Magento development, don’t hesitate to reach out to us at Laravel Company. We’re always here to assist.

Catalog Themes Admin Import/Export

Our network