i have created custom theme in magento 2.2.3 and i want to add some custom block to home page.Please help me how i can add or write code for that.

3 Answers 3


You can directly add block from the admin side

Content > Blocks

Create your block at here

Content > Pages

Call that block in which page you want

  • thanks for replying. i have added normal blocks..just read my above comments, i want custom block... Apr 18, 2018 at 11:20

Create a cms_index_index.xml file in below path


You can add custom block to homepage like below code

<referenceContainer name="content"> //You can change here as per your requirement  
    <block class="Magento\Cms\Block\Block" name="customblock" after="-">
             <argument name="block_id" xsi:type="string">yourblockIdentifier</argument>

you can use below code in your Magento_theme template :

<?php echo $this->getLayout()
          ->toHtml(); ?>
  • thanks for replying...i will you what exactly i want to do. actually i want add a block which will be having two partitions one will be having normal banner and other will be having slider. Apr 18, 2018 at 11:05
  • i have created new custom theme . so for adding custom block sholud i add code in default.xml? Apr 18, 2018 at 11:06
  • @AnilBakale you should create two different block and can call add xml or phtml file.
    – Rv Singh
    Apr 18, 2018 at 11:31

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.