Move search bar from header in home page in magento

Move search bar from header in home page in magento

July 4, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Move search bar from header in home page in magento

Moving the Search Bar on Magento Homepage: A Comprehensive Guide

As a new Magento user, you’ve probably noticed that the built-in search bar is located within the header by default. If you want to move this element to the middle of your homepage while keeping it visible only there, follow our step-by-step guide below.

Understanding Magento’s Default Search Bar Placement

By default, Magento includes a mini-search form in the header.phtml file located at app/design/frontend/{your_vendor}/{your_theme}/template/page/html/header.phtml. This is where the search bar is rendered within the header region of all pages.

The mini-search form is defined using the following HTML:

<div class="mini-cart">
    <a href="#" id="search-toggle" title="<?php echo $this->__('Search') ?>">
        <?php echo $this->getHtml('search', '', array(
            'id' => 'search',
            'action' => $this->getUrl('catalogsearch/result'),
            'class' => 'input-text no-radius',
            ) )
        ?>
    </a>
</div>

Moving the Search Bar to Homepage Middle Section

To move the search bar only on your homepage, we need to create a custom template and override the existing view.

Step 1: Create a New Template File

Navigate to app/design/frontend/{your_vendor}/{your_theme}/template/catalogsearch/form/mini.phtml and copy this file. Paste it in the same location with a new name, for example, mini_homepage.phtml.

Step 2: Customize Your New Template

In your new mini_homepage.phtml file, replace the existing content with the following code:

<div class="homepage-search">
    <?php echo $this->getHtml('search', '', array(
        'id' => 'search',
        'action' => $this->getUrl('catalogsearch/result'),
        'class' => 'input-text no-radius',
        ) )
    ?>
</div>

This code keeps the search form structure intact but removes the mini-cart div, allowing you to style it independently.

Step 3: Apply Custom CSS

Now, let’s create a custom CSS rule for your homepage. Add the following styles to your theme’s main CSS file or a new one:

.homepage-search {
    margin: 0 auto;
    margin-top: 20px; /* Adjust this value based on your layout */
    display: flex;
    justify-content: center;
}

@media (max-width: 768px) {
    .homepage-search input.input-text {
        width: 100%;
    }
}

This CSS centers the search bar and applies responsive styling.

Conclusion

By following this guide, you should now have your Magento search bar moved to the middle of the homepage while remaining invisible on other pages. Remember that customizing your theme’s layout requires understanding both HTML and CSS. If you find yourself needing more advanced solutions or encountering issues with your store setup, don’t hesitate to reach out to our professional Magento development team at Laravel Company.

Happy coding, and feel free to explore more Magento customization options on our blog!

Checkout Catalog Themes

Our network