I have created a block programmatically which shows category name and image on home page. Following is my code:


<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <referenceContainer name="content">
            <block name="homepage.category.thumbnail"
                    <argument name="category_list" xsi:type="object">\Vendor\CategoryCms\ViewModel\CategoryList</argument>

This block taking data from viewmodal and showing in phtml file. If I need to place it on any other page, I need to override that page layout. Is there any way to convert this block to cms block so that we can place it anywhere from admin panel?

2 Answers 2


If you want to add your block to a CMS page, you can add your block into HTML content like below. Otherwise, you know you can add the block XML to any layout file, as you did for the homepage.

<div class="someclass">{{block class="Magento\Framework\View\Element\Template" name="homepage.category.thumbnail" template="Ktpl_CategoryCms::list.phtml" category_list="\Ktpl\CategoryCms\ViewModel\CategoryList"}}</div>

Hope this helps.


It can be achieve by creating widget.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.