How to make logo only H1 on homepage in magento

How to make logo only H1 on homepage in magento

October 2, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How to make logo only H1 on homepage in magento

In Magento, structuring heading tags correctly, especially the H1 tag on your homepage logo, is crucial for both SEO and accessibility purposes. This post will guide you through changing the default behavior of the header.phtml file to make the logo an H1 tag only on the homepage.

Understanding H1 Tag Importance

H1 headers are not just about visual hierarchy; they play a significant role in search engine optimization and improve user experience by providing meaningful structure. For your homepage, having the logo as an H1 tag signals to both users and crawlers that this is the primary content of the page.

Default Magento Behavior

By default, Magento uses an H1 tag for the logo in header.phtml across all pages. This includes category pages, product detail pages, and blog posts—all places where using a single H1 can dilute its importance.

Changing the Behavior

To achieve our goal of having the logo as an H1 only on the homepage, we’ll need to modify the conditional logic in the header.phtml file.

Here’s how you can do it:

  1. Navigate to your theme directory:

    /app/design/frontend/YOUR_THEME/PACKAGE/magento-theme
    
  2. Open the header.phtml file located in the template folder (template/html).

  3. Find and modify this section of code:

<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>
  1. Replace the existing code with this:
<?php if ($this->isHomePage()): ?>
    <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; ?>

Before and After

Before:

<h1 class="logo">...</h1>

After:

<?php if ($this->isHomePage()): ?>
    <h1 class="logo">...</h1>
<?php else: ?>
    <h3 class="logo">...</h3>
<?php endif; ?>

Conclusion

By following these steps, you’ve successfully changed the Magento template to make your logo an H1 tag only on the homepage. This ensures that your website has a strong structural hierarchy and sends clear signals to search engines about the importance of your brand.

Remember, SEO is not just about keywords—it’s about providing a logical structure for both users and crawlers to navigate through your content effectively.

For more advanced Magento template customizations, consider checking out our Magento Development Services at Laravel Company.

Catalog Performance Themes Import/Export

Our network