2

I used onpage.org for an SEO analysis and it told me I have a lot of pages with double h1 tags on my Magento shop. I checked this and it seems my logo is h1 on every page, probably due to the theme, while this should only be on the home page.

I have searched in app/design/frontend/default/theme/template/page/html/header.phtml and found a reference to the h1 tag on the logo, but am not sure what to do, delete this entire code?

<div class="logo-block">
      <?php if ($logoStatus == 0): ?>
        <h1 class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a></h1>
     <?php else:?>
        <h1 class="logo"><strong><?php echo $logoAlt; ?></strong><a href="<?php echo $this->getUrl('') ?>" title="<?php echo $logoAlt; ?>" class="logo"><img src="<?php echo $mediaUrl.$logo; ?>" alt="<?php echo $logoAlt; ?>" /></a></h1>
     <?php endif; ?>
</div>
1
  • Use template path hints on a development box to see which PHTML file is being loaded instead of the default (unless the default file was edited, which is possible too).
    – Phil M
    Nov 10, 2016 at 23:52

1 Answer 1

1

Default Magento templates DO NOT set <h1> on the logo by default you can see in app/design/frontend/base/default/template/page/html/header.phtml :

<?php if ($this->getIsHomePage()):?>
<h1 class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a></h1>
<?php else:?>
<a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a>
<?php endif?>

So I suggest you update your code with the following:

<div class="logo-block">
     <?php if ($this->getIsHomePage()):?>
      <?php if ($logoStatus == 0): ?>
        <h1 class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a></h1>
     <?php else:?>
        <h1 class="logo"><strong><?php echo $logoAlt; ?></strong><a href="<?php echo $this->getUrl('') ?>" title="<?php echo $logoAlt; ?>" class="logo"><img src="<?php echo $mediaUrl.$logo; ?>" alt="<?php echo $logoAlt; ?>" /></a></h1>
     <?php endif; ?>
    <?php else: ?>
      <?php if ($logoStatus == 0): ?>
        <a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a>
     <?php else:?>
        <a href="<?php echo $this->getUrl('') ?>" title="<?php echo $logoAlt; ?>" class="logo"><strong><?php echo $logoAlt; ?></strong><img src="<?php echo $mediaUrl.$logo; ?>" alt="<?php echo $logoAlt; ?>" /></a>
     <?php endif; ?>
    <?php endif; ?>
</div>
2
  • It seems some (bought) themes do this. So I just add this code? Sorry, don't know much/anything about coding.
    – isabelle
    Nov 12, 2016 at 9:37
  • @isabelle yeah just replace the code you posted with the code I posted Nov 12, 2016 at 10:32

Your Answer

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

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