Allow empty cms page content

Allow empty cms page content

August 24, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Allow empty cms page content

Dealing with Empty CMS Page Content in Magento

As a senior developer, I often encounter situations where clients need to create Magento CMS pages with empty content sections, especially for their homepages or landing pages. By default, Magento enforces the requirement of having some content before allowing you to save a page. This can be quite frustrating when you just want an empty layout.

Understanding the CMS Page Structure

In Magento 2, the CMS page structure is defined in the cms_page table. The content and description fields are required, which is why you see that error message when trying to save a blank page.

CREATE TABLE `cms_page` (
    `page_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
    `title` varchar(255) NOT NULL default '',
    `identifier` varchar(255) NOT NULL default '',
    `content` text NOT NULL,
    `content_html` text NOT NULL,
    `description` text NOT NULL,
    PRIMARY KEY (`page_id`)
);

Overcoming the Empty Content Requirement

To allow empty CMS page content, we need to modify the validation rules for these fields. However, directly modifying core files is not recommended due to upgrade issues. The best approach is to create a custom module and override the relevant validation.

Creating a Custom Module

First, let’s create a new module called EmptyCmsPage. Create the necessary folders and files in your Magento 2 installation:

/app/code/EmptyCmsPage
    /etc
        /di.xml
    /registration.php
    /etc/adminhtml/xmls
        /cms_page_form.xml

Overriding the Validation Rules

In di.xml, we’ll override the Magento\Cms\Controller\Adminhtml\Page class to remove the validation rule for empty content:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Cms\Controller\Adminhtml\Page">
        <arguments>
            <argument name="requestValidator" xsi:type="object">
                <class>EmptyCmsPage\RequestValidator</class>
            </argument>
        </arguments>
    </type>
</config>

Now, let’s create the RequestValidator class in our module:

namespace EmptyCmsPage;

use Magento\Framework\App\RequestInterface;
use Magento\Framework\Validation\ValidationException;

class RequestValidator implements \Magento\Framework\Controller\Result\ValidatorInterface
{
    public function validate(RequestInterface $request)
    {
        return true;  // Always return true to allow empty content
    }
}

Finalizing the Setup

Finally, include our module in your project’s composer.json file:

"require": {
    "emptycmspage/module-emptycmspage": "@dev",
    ...
},

After running bin/magento setup:upgrade, you should now be able to create CMS pages with empty content without any validation errors.

Conclusion

While Magento 2 has some limitations in handling empty CMS page content out of the box, creating a custom module and overriding the request validator offers a clean solution. This approach allows for an empty layout while keeping your installation secure and upgrade-friendly.

Remember that for complex scenarios, consider hiring professional services from experienced agencies like Laravel Company, where our team of certified Magento developers can provide tailored solutions to meet your specific business needs.

Don’t hesitate to contact us if you have any questions or need further assistance in customizing your Magento setup. We’re always here to help!

Magento 2 Database Extensions Themes

Our network