Magento2 Layout – ReferenceContainer for Product Page Breadcrumbs

blockscontainerslayoutmagento2xml

I want to add a banner to the top of all the product pages. So far I've added

<referenceContainer name="columns.top">

to the default.xml that links to my template file. This displays the banner, but its under the breadcrumbs and is screwing with the block titles on some of the static pages.

Where should I reference to have my banner above the breadcrumbs, but below the navigation?

Best Answer

The breadcrumbs block is a child block of the page.top container which is itself placed just after header.container

It is declared under Magento\Theme\view\frontend\layout\default.xml:

<referenceContainer name="page.top">
     ...
     <block class="Magento\Theme\Block\Html\Breadcrumbs" name="breadcrumbs" as="breadcrumbs"/>
</referenceContainer>

To place your block before the breadcrumbs you can do the following:

<referenceContainer name="page.top">
    <block class="My\Block\Class" name="my_block" before="breadcrumbs" />
</referenceContainer