Magento 2: I'm trying to add a block to a cms page with a layout overwrite. The problem is the url key has a / at the end which can not be removed. So the url key is uber-uns/ If i remove the / as a TEST it works. Any one got a clue how i do this and keep the /?

app/design/frontend/Company/theme-shopname/Magento_Cms/layout/cms_page_view_id_uber-uns.xml (this works as a test without /) (file content isn't really relevant for the question)

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        <referenceContainer name="main">
            <container name="home-blocks" htmlTag="div" htmlClass="home-blocks">
                <container name="home-blocks-right-wrapper" htmlTag="div" htmlClass="home-blocks-right-wrapper"
                    <container name="home-block-2-wrapper" htmlTag="div" htmlClass="home-block-2 movies-left"
                        <block class="Company\HomePageVideo\Block\HomeVideo" name="block-movies-left"
                            <container name="home-block-2-text" htmlTag="div" htmlClass="home-block-2-text">
                                <block class="Magento\Cms\Block\Block" name="home-block-2">
                                        <argument name="block_id" xsi:type="string">home-block-2</argument>

2 Answers 2


1)From layout .xml file:

<block class="Magento\Cms\Block\Block" name="Promo">
        <argument name="block_id" xsi:type="string">promo</argument>

2)From .Phtml File:

<?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('block_identifier')->toHtml();?>

3)From cms page or block:

{{block class="Magento\\Cms\\Block\\Block" block_id="block_identifier"}}

I hope this may help you.


I wasn't able to figure it out. So i ended up making a html block and adding it to the specific page with the pagebuilder.

{{block class="Company\HomePageVideo\Block\HomeVideo" name="over-ons-video" template="Company_HomePageVideo::over-ons-video.phtml" area="frontend"}}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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