Magento 2 Add a custom element with the class before “main. content” excluding Home Page

Add following code in Magento_Theme/layout/cms_index_index.xml file:

<referenceContainer name="page.wrapper">
           <container name="my.custom.name" as="your-custom" label="Your Label Name" htmlTag="div" htmlClass="my_custom_class" htmlId="my_custom_id" before="page-footer"/>
  </referenceContainer>
  <move element="main.content" destination="my.custom.name"/>

add-custom-element