Now booking projects for this month · Free estimate within 24 hours

How to Add Custom Header in Magento 2

By the Ecomsolver team · Updated Feb 4, 2021 · 2 min read

How to Add Custom Header in Magento 2

As you may know, header is the key element of a website as it is the first thing that people will see when they land on your site. Basically, it contains links to important pages on your site that potential customers will often want to visit before making a purchase or enquiry. It sets the tone for the whole site. You need to include adequate information in the header to encourage your customers to explore your site further.

In this blog today, we presented the way to Add Custom Header in Magento 2.

Step 1: Create an XML file on the following path –>

app/design/frontend/Vendor/Theme/Magento_Theme/layout/default.xml

<referenceContainer name="header.container">
<block class="Magento\Framework\View\Element\Template" name="custom_header" as="custom_header" template="Magento_Theme::html/customheader.phtml" before="-"/>
</referenceContainer>
<move element="logo" as="logo" destination="custom_header"/>
<move element="top.search" as="topsearch" destination="custom_header"/>
<move element="minicart" as="minicart" destination="custom_header"/>
<move element="store_language" as="store_language" destination="custom_header" />

Step 2: Create HTML file on the following path –>

app/design/frontend/Vendor/Theme/Magento_Theme/templates/html/customheader.phtml
Place this line in the code –

<?php echo $this->getChildHtml("store_language"); ?>

After placing the above code your new Header version is now applied. You just need to refresh your page and you can see it in the frontend. Hopefully, this solution will be a help for you to add custom header in Magento 2 and make your site more attractive and clearer. Still having a problem then please contact us.

Ecomsolver is an Indian Web Design and Development firm with having a team of experts striving to provide you world class web solutions at cost nominal price. A good track of successful records has made Ecomsolver renowned in this field. Planning to develop an online business site then drop us a line.

Let's talk

Ready to get your project moving?

Pick whichever is easiest for you. Every channel reaches a real person on our team, and we reply within 24 hours (usually much faster).

India (HQ)401, Big Benn Mall, Okay Plus, Sunder Singh Bhandari Nagar, Jaipur, Rajasthan 302019, India
USA3532 Bee Cave Rd, Austin, TX 78746, United States

Send us your project

Free quote

Short and simple. We will come back with questions or an estimate.

Please enter your name and a valid email.

Reply within 24hYour info stays private

Looking for a job? This form is for client projects. Apply on our Careers page with your resume.

Got it, thank you!

Your request is with our team. A senior developer will reply within 24 hours with questions or a first estimate.

Continue on WhatsApp
Chat with us
WhatsApp Call Free Quote