2

I have developed a custom homepage layout and applied to the homepage. I've tried to add a created block in Magento_theme/templates/html/homepage.html but it is not displaying. Can anyone check problem in my code?

   <body>
    <update handle="empty"/>
    <referenceContainer name="page.wrapper">
        <container name="header.container" as="header_container" label="Page Header Container"  htmlTag="header" htmlClass="page-header" before="main.content"/>
        <container name="page.top" as="page_top" label="After Page Header" after="header.container"/>
        <container name="footer-container" as="footer" before="before.body.end" label="Page Footer Container" htmlTag="footer" htmlClass="page-footer" />
    </referenceContainer>

      <referenceContainer name="main.content">
          <block class="Magento\Framework\View\Element\Template" name="burgHomepage" template="Magento_Theme::html/homepage.phtml" />
      </referenceContainer>
    </body>
  • Please show FUll XML code and where you added this – Manoj Deswal Jul 11 '17 at 9:03
  • You can create blocks and display them via widgets on homepage – Manoj Deswal Jul 11 '17 at 9:03
  • @ManojDeswal Updated now, sorry! I added it in my custom homepage layout magento_theme/page_layout/homepage.xml – Tom Jul 11 '17 at 9:04
  • why you are using body tag in between of code? – Manoj Deswal Jul 11 '17 at 9:09
  • @ManojDeswal I saw it on an answer on another question and I was just trying it, I can get my header and footer to show ok, in the middle it just says Home Page and my block doesnt show, do you know what I am doing wrong? – Tom Jul 11 '17 at 9:12
4

Create Your Custom Homepage in 4 Simple steps via admin only

1 ) Create a page For example custom-homepage Now you can directly put your content here and the go through with 4th step

2 ) For easy management of sections Create multiple blocks and put content which you want to display at homepage ex: home-block1 , home-block2

3 ) Call those block to your custom-homepage using below code

{{block class="Magento\\Cms\\Block\\Block" block_id="home-block1"}}
{{block class="Magento\\Cms\\Block\\Block" block_id="home-block2"}}

4 ) Now Final step to display your custom-homepage as main homepage

Admin > Stores > Configuration > General > Web > Default Pages > CMS Home Page

I hope this will make you work easy

Thanks

0

if you use Magento_Theme then your PHTML file should be located in

vendor/magento/module-theme/view/frontend/templates/homepage.phtml

please check it , or in your theme app/design/YourPackage/YourTheme/ in this folder create directory Magento_Theme/templates/ and put your homepage.phtml in that folder

  • Thank you, how would I then tell Magento to use this as my homepage? – Tom Jul 11 '17 at 9:47
  • @Tom your question is not clear to me – Murtuza Zabuawala Jul 11 '17 at 9:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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