cancel
Showing results for 
Search instead for 
Did you mean: 

Changing logo in admin theme

SOLVED

Changing logo in admin theme

I am trying to simple change the logo shown on the admin login page. After creating the following files i have run

magento setup:upgrade
magento setup:static-content:deploy -f
magento setup:di:compile
magento cache:clean

 

app/design/adminhtml/Myvendor/mycustomadmintheme/theme.xml

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
<title>My custom admin theme</title>
<parent>Magento/backend</parent>
</theme>

 

app/design/adminhtml/Myvendor/mycustomadmintheme/registration.php

<?php
 \Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::THEME,
'adminhtml/Myvendor/mycustomadmintheme',
__DIR__
);

 

app/design/adminhtml/Myvendor/mycustomadmintheme/Magento_Backend/layout/default.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="logo">
            <arguments>
                <argument name="logo_file" xsi:type="string">images/mycustom_logo.png</argument>
                <argument name="logo_width" xsi:type="number">283</argument>
                <argument name="logo_height" xsi:type="number">85</argument>\
                <argument name="logo_alt" xsi:type="string">custom_logo</argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

 

app/design/adminhtml/Myvendor/mycustomadmintheme/Magento_Backend/layout/admin_logo.xml

<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/mycustom_logo.png</argument>
                <argument name="logo_width" xsi:type="number">283</argument> <!-- Add custom logo width -->
                <argument name="logo_height" xsi:type="number">85</argument> <!-- Add custom logo height -->
            </arguments>
        </referenceBlock>
    </body>
 </page>

the di.xml file in etc folder of my working module is as follows:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Theme\Model\View\Design">
        <arguments>
             <argument name="themes" xsi:type="array">
                 <item name="adminhtml" xsi:type="string">Myvendor/mycustomadmintheme</item>
             </argument>
         </arguments>
    </type>
</config>

despite all this the logo stays the same. however when i open the logo image in new tab, i can see that the magento logo is pulled from static/version1704465742/adminhtml/Myvendor/mycustomadmintheme/en_US/images/magento-logo.svg

 

So, the theme is working but the default.xml or admin_logo.xml is not. Can anyone tell me where i am going wrong, the magento version is 2.4

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Changing logo in admin theme

The filename should have been admin_login.xml. Resolved.

View solution in original post

2 REPLIES 2

Re: Changing logo in admin theme

The filename should have been admin_login.xml. Resolved.

Re: Changing logo in admin theme

Hello @raza19,

Method to Change Default Admin Logo in Magento 2:

For the Admin Login Page:

Create an admin_login.xml file at view/adminhtml/layout/

<?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/Milople.png</argument>

            </arguments>

        </referenceBlock>

    </body>
</page>

For the Default Logo in Backend Menu:

Create a default.xml file in your custom module at view/adminhtml/layout/

<?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/Milople.png</argument>

                </arguments>

            </block>

        </referenceContainer>

    </body>

</page>

After this run compile and deployment commands and then check logo will be changed.

If you still have any questions you can contact us.