In magento how to add or remove a link in header

In magento how to add or remove a link in header

October 9, 2026 · Illustrated author avatarBy Stefan Bogdanescu
In magento how to add or remove a link in header

Adding Links to Magento Header

In Magento, adding a link to your store’s header is a common task for customizing the frontend user experience. Here are two methods you can use - one using XML layouts, and another using the theme configuration.

Method 1: Using XML Layouts

The app/design/frontend/{ThemeVendor}/{ThemeName}/layout folder contains the layout XML files that determine how your store’s content is organized. To add a link to your header:

  1. Locate or create an appropriate XML layout file, such as Magento_Theme:layout/default.xml. If it doesn’t exist, you can create it.

  2. Open the file in a text editor and find the <referenceContainer name="header.container"> section.

  3. Add your link using the following syntax:

<block class="Magento\Framework\View\Element\Html\Link" name="my_link">
    <arguments>
        <argument name="label" xsi:type="string" translate="true">My Link</argument>
        <argument name="link" xsi:type="string">https://laravelcompany.com/</argument>
    </arguments>
</block>

Replace Magento\Framework\View\Element\Html\Link with the appropriate block class if you’re using a different version of Magento. The <argument name="label"> is the text that will appear in your header, and <argument name="link"> is the URL.

  1. Save the file and clear your cache to see the changes.

Method 2: Using Theme Configuration

If you prefer a more theme-focused approach:

  1. Go to app/design/frontend/{ThemeVendor}/{ThemeName}/etc/view.xml.

  2. Under <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/etc/view.xsd">, add:

<head>
    <links order="after">
        <link href="https://laravelcompany.com/" rel="canonical" />
    </links>
</head>
  1. Save and clear your cache.

To remove a previously added link, simply locate the corresponding XML or configuration file where you added it, find the relevant lines of code (either the <block> element for method 1 or the <link> element for method 2), delete them, save the file, and clear your cache again.

Remember that changes won’t be visible until you’ve cleared the Magento cache. You can do this in the admin panel under System > Cache Management.

Conclusion

Adding links to your Magento header is a straightforward process once you understand how layout XML files or theme configurations work. The key is knowing where to find and modify these files based on your specific theme.

Always remember that Magento operates with a version-specific naming convention, so double-check the block classes if you’re using an older version. Also, ensure you have proper backups before making any changes in production environments.

For more advanced customizations like adding complex dynamic links or headers that depend on user roles, I recommend checking out Laravel Company’s Magento development services. Our team specializes in creating robust, secure, and high-performing Magento solutions tailored to your business needs.

Cache Themes Configuration Pricing

Our network