How to show a block on the frontend home page only inside Magento 2 version

For block deceleration inside latest magento 2 version, we need a block layout file .
The naming of the file is important as this is the new way of using layout handles.
magento showing block , training in delhi
ex cms_index_index.xml .
This will make our block only appear on the home page .
Here each word of file name are in magento naming convenation i.e module_controller_action.xml.

 

 

 

 

So, If you want to declare block

for magento theme

Place block declaration into the Magento_Theme/layout/cms_index_index.xml file.

for magento module

place block declaration into the app/code///view/frontend/layout
ex:

<?xml version="1.0"?>
 
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
      <referenceContainer name="page.top">
 
 		    <container name="banner" as="banner" label="Banner"   htmlTag="div" htmlClass="banner" htmlId="banner">
				<block class="Magestore\Bannerslider\Block\Bannerslider" name="bannerslider.content.top" before="-" />
		   </container>
		 
    </referenceContainer>
	 
</body>
</page>

Online Web Development Training,Video Tutorials