How to move my Magento mini search form to another spot in my template header?

How to move my Magento mini search form to another spot in my template header?

October 7, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How to move my Magento mini search form to another spot in my template header?

Moving Your Magento Mini Search Form to Another Spot in Your Template Header

Introduction

As you embark on your first custom Magento theme development journey, you’re likely facing challenges along the way. One common issue is moving elements like the mini search form from their default positions to new locations within your template header.

In this guide, we’ll walk through the process of relocating your mini search form from its original bar on the home page to a new spot in your custom header.

Understanding Magento’s Header Structure

Before diving into the code changes, let’s first understand how Magento’s default header is structured. The header.phtml file contains several key elements:

  • The logo block
  • The top search block (where we’ll focus)
  • The top links block
  • The top menu block

Locating and Relocating the Mini Search Form

In your current theme, you’ve set up your header like this in header.phtml:

<div id="header">
    <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>
    <div id="header-top">
        <?php echo $this->getChildHtml('topSearch') ?>
        <?php echo $this->getChildHtml('topLinks') ?>
    </div>
    <?php echo $this->getChildHtml('topMenu') ?>
</div>

The mini search form is rendered by the line <?php echo $this->getChildHtml('topSearch') ?>. However, it’s not appearing on your live site because Magento hasn’t been configured to render that block in this specific position.

To fix this, we need to update two files: local.xml and CMS pages.

Updating the local.xml File

The local.xml file is where you configure which blocks appear in your layout. Open your theme’s app/design/frontend/<your_package>/<your_theme>/layout/local.xml file.

Look for a line that defines the header block:

<block type="page/html_header" name="header" as="header">
    <action method="setTemplate"><value>page/html/header.phtml</value></action>
    <action method="setLayout"><value>1column</value></action>
    ...
</block>

Add the topSearch block to this definition:

<block type="core/text_list" name="top.search">
    <action method="addLink" ifconfig="top_menu/enabled">
        <label>Top Search</label>
        <url helper="catalog/getSearchUrl"/>
        <title helpid="search.title"></title>
        <prepare/>
    </action>
</block>
<block type="page/html_header" name="header" as="header">
    ...
    <block type="core/text_list" name="top.links">
        <block type="page/top_link" name="top.search">
            <action method="addLink" ifconfig="top_menu/enabled">
                <label>Top Search</label>
                <url helper="catalog/getSearchUrl"/>
                <title helpid="search.title"></title>
                <prepare/>
            </action>
        </block>
    </block>
</block>

This tells Magento to render the top.search block within your header.

Updating CMS Pages

Now, let’s configure the CMS pages that will use this new layout. In your admin panel, navigate to Content > Pages. Find the home page (usually named something like “Home Page” or “CMS Home”) and edit it.

Under the Design tab, ensure you have selected your custom theme as the Theme option. If not, choose it from the dropdown menu.

Click Save.

Reloading Your Cache

Magneto uses cache to store layout configurations and other data for performance optimization. To see your changes:

  1. Log out of your admin panel.
  2. Flush Magento’s cache in the admin panel by going to System > Cache Management.
  3. Select all cache types (except “Config” and “Layout XML files”).
  4. Click Flush Cache.

Now, log back into the frontend of your site.

Conclusion

Relocating elements like search forms within your Magento theme requires a combination of editing layout files (local.xml) and configuring CMS pages to use those layouts. By following this guide, you’ve successfully moved your mini search form from its default position in the header to a new spot defined by your custom header.phtml file.

Remember, Magento’s structure can be complex for beginners. If you’re struggling with layout configurations or other theme development tasks, consider exploring our comprehensive guides on Magento theme development at Laravel Company.

Happy coding!

Themes Errors

Our network