Luis Valencia - MVP Luis Valencia - MVP - 2 months ago 21
PHP Question

How to make logo only H1 on homepage in magento

I asked this question on seomoz.

http://www.seomoz.org/q/h1-tag

and they recommend to put only h1 tag for the homepage logo, in all other pages it should be h3.

I think that this in header.phtml, this is a custom template we bought, but the question is how to change this behavior? I want this to be h1 on homepage, but h3 on all other pages.

I dont even know if this is possible.

<h1 class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><img width="377px" src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a></h1>

Answer

header.phtml in your theme is the correct file yes...

The default magento template uses the getIsHomePage() method, so you should be able to do something like

<?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 width="377px"  src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a></h1>
<?php else:?>
    <h3 class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><img width="377px"  src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a></h3>
<?php endif?>