How to Create Magento 2 CMS Blocks?

If merchants need to announce special offers, show banners, or just make their pages more engaging, they need Magento CMS blocks.

These blocks can be easily created directly from the admin panel. However, as the number of blocks grows, managing them efficiently may become challenging.

So, in this article, you'll learn how to create CMS blocks in Magento, what they are used for, and how to make the most of their usage. We'll also cover how to schedule CMS blocks in Magento for better block management.

Key takeaways
  • Magento 2 CMS blocks are reusable content units that can display text, images, videos, links, buttons, and widgets across multiple locations on your website.
  • The blocks can be added to CMS, category, product, cart, checkout and other pages.
  • Widgets are the most flexible method for displaying static blocks on any page or layout position.
  • Unlike CMS pages, CMS blocks do not have their own URLs and are designed for repeated use.
  • The static blocks support localisation and store-view-specific content.
  • By default, CMS blocks are static and require manual updates, activation, and deactivation.
  • Dynamic CMS blocks can be shown based on customer groups, cart attributes, product attributes, and date.

What Are Magento 2 CMS Blocks?

Magento 2 CMS blocks are the reusable content blocks that are part of Magento CMS and allow displaying the same information in multiple places on a Magento website. Static blocks can store texts, images, videos, buttons, links, and widgets.

They are most commonly used for different promotional banners (sales, discounts, special offers), trust badges, store announcements, seasonal content, or campaign-based messages.

Once created, a static block can be shown on CMS page, category, product, checkout and other pages.

Difference Between CMS Blocks and CMS Pages in Magento

Magento CMS blocks and CMS pages are related, working together to build content on a store, but they each have different functions.

CMS blocks are content units that can be created once and inserted multiple times into different pages or locations. 

CMS pages are separate pages with their own URLs, like the About Us and Contact pages, etc. They are meant as separate units that form the main structure of the website.

magento cms blocks vs cms pages

Why Magento CMS Blocks Matter?

One of the main purposes of Magento CMS blocks is efficiency. They allow updating content on many different pages by editing a single static block directly from the admin panel.

This is why they aren't just a tool to create content — they are a powerful way to:

  • speed up and simplify content management 
  • maintain the same content and design across the entire store
  • localize or change content per different store views 
  • support marketing campaigns quickly without involving developers

Thus, CMS blocks give business teams more flexibility to keep their storefront consistent and relevant.

How to Create CMS Blocks in Magento 2?

To create Magento CMS blocks:  

Step 1: Navigate to Content > Elements > Blocks and press the Add New Block button.

Step 2: Enable the CMS Block, and give it a Title and Identifier.

Step 3: Assign a block to the Store View it should be displayed on. It's especially important for stores with multi-language setups.

Magento 2 New CMS Block

Step 4:  Create CMS Block Content by adding images, videos, links, and other content.

Magento 2 Create New CMS Block

Step 5:  Don't forget to Save the block once finished.

Note: if you're comfortable working with code, try to create CMS blocks in Magento 2 programmatically

Where to Add CMS Blocks in Magento?

Inserting CMS blocks in Magento depends on goals and the type of page where the block should appear:

  • Any page. To display a static block on any page, widgets are the most flexible option, since they allow you to choose any location (header, footer, sidebar) on a page.
  • CMS page or blog posts. To add static blocks directly into the CMS page or blog, use the widgets feature available in the WYSIWYG editor. Ideal option for banners, promotional content, or text sections located between other elements.
  • Category pages. Category pages have specific places dedicated to promo content. The CMS blocks can be assigned directly in the category settings for category-specific offers.
  • Checkout success page. The same widget approach applies here. Additionally, it's possible to define conditions under which to  add CMS block on checkout in Magento.

Now, that you know how to create and where to display Magento CMS blocks, it's time to check how to get the most out of them. With personalised offers.

How to Enable Dynamic CMS Blocks in Magento?

To enable dynamic CMS blocks in Magento, you need tools like Magefan Dynamic Blocks and Pages for Magento 2

By default, CMS blocks are static. This means merchants still need to enable or disable the blocks when promotions expire, manually update the content, and create separate blocks for different audiences.

And the more powerful their promotion campaign is, the more time-consuming it may become. 

Magento 2 Dynamic Blocks and Pages extension, on the other hand, allows merchants to display static blocks automatically based on various conditions.

Let's take the same "free shipping for orders over $200" offer as an example.

Based on customer groups

For your CMS block to drive the attention of the right audience, you need to target it with the right offer. Therefore, the same block won't work for everybody. To solve this dilemma, create unique blocks for each customer group.

e.g. you can offer free shipping only for general customers (those logged in).

magento 2 cms block restrictions for customer group

Customer group setting for the dynamic blocks

Based on cart attributes

The "free shipping for orders over $200" block should be displayed for people whose total hasn't passed the $200 threshold. That's when cart attributes come in handy. But subtotal is not the only attribute you can choose.

e.g. you can choose to offer free shipping only to one country

magento 2 cart attributes in conditions

Example of the CMS block conditions based on the cart attributes (shipping country and cart subtotal)

Based on product attributes

If you decide to display a CMS block with some offers on product pages, you can narrow down the options with the product attributes.

e.g. you can display the free shipping offer only on certain categories or only on new products.

magento 2 product attributes in conditions

Example of the CMS block conditions based on the product attributes.

Based on date

Finally, the most important part. To eliminate manual work, you need to schedule CMS blocks for certain dates, times, and days of the week. The extension automatically disables and enables the static block based on your settings.

e.g. you can offer free shipping from 8 a.m. to 2 p.m., Monday through Wednesday, during a certain period.

magento dynamic blocks date

Dynamic blocks date and time settings

At this point, it's clear how static blocks work in Magento, where they can be shown, and why dynamic rules are essential for managing promotions efficiently.

The next step is making sure you follow the best practices.

Magento 2 CMS Blocks Best Practices

In order to keep the storefront consistent and up to date with CMS blocks, there are some best practices to follow:

  • Name the blocks clearly. Assign a clear and descriptive name to each CMS block to understand what it is used for. This way, the block will be easy to find and update. It's especially helpful for stores with many campaigns, seasonal messages, or multiple contributors.
  • Reuse the blocks. To save time and stay consistent, reuse existing static blocks instead of recreating content on different pages.
  • Be attentive when assigning store views. Always double-check that CMS blocks are assigned to the correct store view. Proper settings ensure the right content appears in the right place without confusing customers.
  • Regularly review and clean up CMS blocks. Disable or remove outdated or no longer needed blocks to keep your CMS library clean and up to date. This improves efficiency and makes content management easier.
  • Display static blocks dynamically to automate and personalize content. For stores with frequent promotions, enable Magento dynamic pages. They allow you to apply rule-based logic and automatically control when, where, and to whom the blocks are shown.

As you can see, Magento CMS blocks are a perfect way to level up your promotions and manage content across multiple pages faster. Moreover, if you pair it with the right tools, you can show content dynamically to different customers and upgrade the management even more.

FAQs

Can't see any CMS blocks in admin panel Magento. Why?
collapsible icon
You may not see CMS blocks in the Magento admin panel due to incorrect admin user role permissions or cached admin data. Check the admin user role configuration, flush Magento caches, log out of the admin panel, and log in again.
What is the correct way to insert a CMS block in a layout in Magento?
collapsible icon
A CMS block is inserted into the layout by using the Magento/Cms/Block/Block class with the block_id argument. When you use this class in a layout XML file, Magento knows to fetch the content of the CMS block from the database.
How to call CMS static block in .phtml file in Magento 2
collapsible icon

You can call a CMS static block in a .phtml file by rendering it through Magento layout block:

= $this->getLayout() ->createBlock(\Magento\Cms\Block\Block::class) ->setBlockId('your_block_identifier') ->toHtml(); ?>

Just replace 'your_block_identifier' with your CMS block ID.

Is there a way to display a Magento static block only on mobile?
collapsible icon
Magento doesn't offer this by default. You need Magefan Dynamic Blocks and Pages for Magento, which allows to display unique CMS blocks for each device: mobile, tablet, or desktop.