Magento2 – Modify Default Admin Logo in Login Portal and Backend Menu

adminhtmlbackendmagento2

I would like to change both the logo in the login admin portal and the Magento icon at the top left of the admin menu.

What is the easiest way to do that, according images I want to upload are PNG files (I am not familiar with SVG format)
Thanks for your help.

Best Answer

In order to change top left logo of the admin menu you have to create in your custom module view/adminhtml/layout/default.xml file:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="header">
            <block class="Magento\Backend\Block\Page\Header" name="logo" before="-">
                <arguments>
                    <argument name="show_part" xsi:type="string">logo</argument>
                    <argument name="edition" translate="true" xsi:type="string">Community Edition</argument>
                    <argument name="logo_image_src" xsi:type="string">images/custom-admin-icon.svg</argument>
                </arguments>
            </block>
        </referenceContainer>
    </body>
</page>

Place custom-admin-icon.svg with height 25px and width 41px into CustomModule/view/web/images/custom-admin-icon.svg

For the Admin Login page create new view/adminhtml/layout/admin_login.xml file:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-login" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
    <referenceBlock name="logo">
        <arguments>
            <argument name="logo_image_src" xsi:type="string">images/custom-admin-logo.svg</argument>
        </arguments>
    </referenceBlock>
</body>

Feel free to use PNG files instead of SVG.

Related Topic