I've created multiple custom pages like a contact page and FAQ page but both the pages and the containers I've labeled don't show up in the widget panel.
What's the right way to add widgets to your custom pages?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityadd a page_types.xml within your module. The path will be etc/frontend/page_types.xml
in this you can define the page_types as below
<?xml version="1.0"?>
<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_types.xsd">
<type id="mycustom_controller_index" label="My Custom Intex Controller"/>
</page_types>
after that, you can select this into Display On:: Specified Page section into the admin area of the widget.
as shown below
First: create new page layout under app/design/frontend///Magento_Theme/layouts.xml. Assign template to specific page(s)
<?xml version="1.0" encoding="UTF-8"?>
<page_layouts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/PageLayout/etc/layouts.xsd">
<layout id="layout-id">
<label translate="true">Layout name</label>
</layout>
</page_layouts>
Clear cache:
php bin/magento cache:cle
Second: Create new page type in your custom module and map new page in your widget
<?xml version="1.0"?>
<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_types.xsd">
<type id="cms_page_view_id_About-us" label="About Us"/>
</page_types>
Clear cache:
php bin/magento cache:clean
References: