skip to Main Content

I’m using Magento 2.2, and I’m wondering, how would I remove the header and footer ONLY from the home page? I use various stores, so the home page just acts as a portal to each store.

I explicitly only want to remove the header and footer from the home page. They should appear on all other pages.

Thank you.

3

Answers


  1. I’m sure there are other ways of not rendering the content in the backend code, but you can certainly do it in CSS as well.

    .cms-home .header {
        display: none;
    }
    
    .cms-home .page-footer {
        display: none;
    }
    

    If you’re looking for a code solution, I believe you would override one of the xml layout files to do this. It has been a while since I have done anything with Magento, so I’m not sure if that’s possible, but it should be if I remember correctly.

    This looks like it could be a good example to go on for removing it using the layout xml option: How to remove ‘Subscribe’ field from Luma footer

    Login or Signup to reply.
  2. The beste way of doing this is to remove the header and footer from your XML-Rendering file. If you only hide it with CSS then this section will be rendered and need some resources. You can try something like this:

    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
      <body> 
          <referenceBlock name="header.container" remove="true" />  
          <referenceBlock name="footer.container" remove="true" />
      </body> 
    </page> 
    
    Login or Signup to reply.
  3. You need to overwrite cms_index_index.xml layout. Then it will apply change only to home index page

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search