Get list of Layout XML called for a current page Magento 2.

You can get a list of called Layout XML for specific pages by Magento\Framework\App\View class.

Call getLayout() method from Magento\Framework\App\View.php class.

getLayout()->getUpdate()->getHandles() used for getting all the handles of a page.

You need to keep below code at the end of root index.php file to check the available layout XML files for a page.

<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$xmlLayout = $objectManager->get(\Magento\Framework\App\View::class);
var_dump($xmlLayout->getLayout()->getUpdate()->getHandles());

To check for a specific page, You need to call like below way,

public function __construct(
    \Magento\Framework\App\ViewInterface $view
) {
    $this->view = $view;
}

Call Inside a function,

// collect loaded handles for a current page
$loadedHandles = $this->view->getLayout()->getUpdate()->getHandles();

Now you can print the result $loadedHandles from above expression.

  • Example of a different Pages loaded handles:

For all the pages, default.xml is the first layout handle to call in a page and after that based on page handle, other XML layouts are rendering.

For Homepage,

Array
(
[0] => default
[1] => cms_index_index
[2] => cms_page_view
[3] => cms_index_index_id_home
)

For Product page,

Simple Product Page,

Array
(
    [0] => default
    [1] => catalog_product_view
    [2] => catalog_product_view_type_simple
    [3] => catalog_product_view_id_9
    [4] => catalog_product_view_sku_{SKUName}
)

Configurable Product Page, 

Array
(
    [0] => default
    [1] => catalog_product_view
    [2] => catalog_product_view_type_configurable
    [3] => catalog_product_view_id_153
    [4] => catalog_product_view_sku_{SKUName}
)

Search Page,

Array
(
    [0] => default
    [1] => catalogsearch_result_index
)

Category Layered page,(Is Anchor Enable)

Array
(
    [0] => default
    [1] => catalog_category_view
    [2] => catalog_category_view_type_layered
    [3] => catalog_category_view_id_{CATEGORY_ID}
)

Non-Layered Page,

Array
(
    [0] => default
    [1] => catalog_category_view
    [2] => catalog_category_view_type_default
    [3] => catalog_category_view_id_{CATEGORY_ID}
)

For Cart Page,

Array
(
    [0] => default
    [1] => checkout_cart_index
)

For Login page,

Array
(
    [0] => default
    [1] => customer_account_login
)

For About Us CMS Page,

Array
(
    [0] => default
    [1] => cms_page_view
    [2] => cms_page_view_id_about-us
)