I have successfully created a custom theme as a child of Luma theme in my Magento CE 2.0.12 installation.

But if I add below code in my layout/theme.xml file, I am not able to add a title attribute to img tag of Logo:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <referenceBlock name="logo">
              <argument name="logo_file" xsi:type="string">images/mytheme_logo.svg</argument>
              <argument name="logo_alt" xsi:type="string">Custom Alt</argument>
              <argument name="logo_title" xsi:type="string">Custom's Logo</argument>
              <argument name="logo_img_width" xsi:type="number">200</argument>
              <argument name="logo_img_height" xsi:type="number">200</argument>

Please suggest how to add additional attribute to img tag of Logo.

  • Hello Vicky, Changing via admin can not be an option? Feb 11, 2017 at 1:02
  • Tried that but it doesn't work with custom theme.
    – Vicky Dev
    Feb 11, 2017 at 8:45
  • This question needs to be upvoted so that it can get much attention, this could help a lot.
    – Vicky Dev
    Feb 11, 2017 at 12:32

1 Answer 1


You need to override template of logo.phtml into your custom theme.

Follow below steps :

  1. Assuming you have already created custom theme and its working fine and activated !! (Location is : app/design/frontend/VendorName/themename)
  2. Create one folder in the your custom theme directory name Magento_Theme
  3. Now create logo.phtml file in "Magento_theme/templates/html/header/logo.phtml" on this location.
  4. Copy your default logo.phtml file from theme and paste its content into your custom logo.phtml file. Add title attribute to that image tag.

logo.phtml code should be like below :

 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.

// @codingStandardsIgnoreFile

 * @var \Magento\Theme\Block\Html\Header\Logo $block
<?php $storeName = $block->getThemeName() ? $block->getThemeName() : $block->getLogoAlt();?>
<span data-action="toggle-nav" class="action nav-toggle"><span><?php /* @escapeNotVerified */ echo __('Toggle Nav') ?></span></span>
<?php if ($block->isHomePage()):?>
    <strong class="logo">
<?php else: ?>
    <a class="logo" href="<?php echo $block->getUrl(''); ?>" title="<?php /* @escapeNotVerified */ echo $storeName ?>">
<?php endif ?>
        <img src="<?php /* @escapeNotVerified */ echo $block->getLogoSrc() ?>"
             alt="<?php /* @escapeNotVerified */ echo $block->getLogoAlt() ?>"
             <?php echo $block->getLogoWidth() ? 'width="' . $block->getLogoWidth() . '"' : '' ?>
             <?php echo $block->getLogoHeight() ? 'height="' . $block->getLogoHeight() . '"' : '' ?>
       title="TESTESTESTEST" />
<?php if ($block->isHomePage()):?>
<?php else:?>
<?php endif?>

Here i have added title="TESTESTESTEST" it shows on the logo image. Clear the cache and check

  • @VickyDev Thank you !! Happy to help , Keep helping :) Feb 11, 2017 at 8:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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