3

I am trying to change Magento2.2.2 admin logo.
But no success.
This is what I have done:

This file app/design/adminhtml/XXX/yyy/theme.xml contains:

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

This file app/design/adminhtml/XXX/yyy/registration.php contains:

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

This file app/design/adminhtml/XXX/yyy/Magento_Theme/layout/default.xml contains:

<?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">
<head>
  <title>Admin Title</title>
</head>
<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/my-logo.svg</argument>
        <argument name="logo_alt" xsi:type="string">My Admin</argument>
      </arguments>
    </block>            
  </referenceContainer>
</body>

And finally my logo image is in
app/design/adminhtml/XXX/yyy/web/images/my-logo.svg

5

Try this code:

  1. app/code/[VendorName]/[ModuleName]/registration.php
<?php \Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    '[VendorName]_[ModuleName]',
    __DIR__
);?>
  1. app/code/[VendorName]/[ModuleName]/etc/module.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="[VendorName]_[ModuleName]" setup_version="1.0.0">
        <sequence>
            <module name="Magento_Theme"/>
        </sequence>
    </module>
</config>
  1. app/code/[VendorName]/[ModuleName]/etc/di.xml
<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">[VendorName]/[themename]</item>
            </argument>
        </arguments>
    </type>
</config>
  1. app/design/adminhtml/[VendorName]/[themename]/registration.php
<?php \Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::THEME,
    'adminhtml/[VendorName]/[themename]',
    __DIR__
);?>
  1. app/design/adminhtml/[VendorName]/[themename]/theme.xml
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
    <title>Theme Title</title>
    <parent>Magento/backend</parent>
</theme>
  1. app/design/adminhtml/[VendorName]/[themename]/Magento_Backend/layout/admin_login.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">
    <update handle="styles" />
    <body>
        <referenceBlock name="logo">
            <arguments>
                <argument name="logo_image_src" xsi:type="string">images/login-logo.svg</argument>
            </arguments>
        </referenceBlock>
    </body>
</page>
  1. app/design/adminhtml/[VendorName]/[themename]/web/images/login-logo.svg
  2. app/design/adminhtml/[VendorName]/[themename]/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>
        <referenceContainer name="header">
            <referenceBlock name="logo">
                <arguments>
                    <argument name="logo_img_width" xsi:type="number">300</argument> 
                    <argument name="logo_img_height" xsi:type="number">300</argument>
                    <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/menu-logo.svg</argument>
                </arguments>
            </referenceBlock>
        </referenceContainer>
    </body>
</page>
  1. app/design/adminhtml/[VendorName]/[themename]/web/images/menu-logo.svg
  2. Magento CLI
php bin/magento setup:upgrade
php bin/magento setup:di:compile

Note:

  1. For Admin login page logo change, follow steps - 6 & 7
  2. For Admin menu logo change, follow steps - 8 & 9

Note: Feel free to use PNG files instead of SVG for logo.

Note: If changes not reflected on Admin pages then try below steps:

  1. Uninstall a manually added theme

    • mysql -u <user> -p -e "delete from <dbname>.theme where theme_path ='<VendorName>/<themename>' AND area ='adminhtml' limit 1"
  2. Upgrades the Magento application, DB data, and schema

    • php bin/magento setup:upgrade
    • php bin/magento setup:di:compile - (Optional)
    • php bin/magento setup:static-content:deploy -f
    • php bin/magento c:c && php bin/magento c:f

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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