Displaying Top-Links in Magento Footer
As an experienced developer, I understand your frustration when customizations don’t work as expected in Magento. Let’s troubleshoot this issue step-by-step.
Understanding the Top-Link Structure
Firstly, it’s crucial to understand how top-links are structured and displayed. By default, Magento includes a top.links block that contains links like ‘Home’ or ‘Company Information’. This is defined in your current theme’s layout XML file (usually app/design/frontend/{package}/{theme}/layout/default.xml).
The Issue with Your Current Code
You’re on the right track by using $this->getChildHtml('topLinks') in your footer.phtml, but the issue lies in the way you’ve added this block to your layout.
In Magento 2, blocks are typically added to the page hierarchy through the main layout XML file (app/design/frontend/{package}/{theme}/layout/default.xml). You need to ensure that your topLinks block is properly inserted into the page structure.
The Correct Approach
To display the top.links in your footer:
-
Open your theme’s
default.xmlfile located atapp/design/frontend/{package}/{theme}/layout/. -
Locate the
<referenceBlock name="footer-container" />block. This is where we’ll insert our topLinks. -
Add the following inside this referenceBlock:
<action method="setIsNested">
<argument name="value" xsi:type="boolean">false</argument>
</action>
<block class="Magento\Framework\View\Element\Template" before="-" template="Magento_Theme::html/top.links.phtml" after="footer-container" name="top.links" />
This code adds the top.links block to your footer, ensuring it appears exactly where you want it.
- Save the file and clear your cache (
bin/magento cache:clean).
Verifying the Changes
After implementing these changes, navigate back to your storefront’s footer section. You should now see the top-links you expected:

Remember, Magento 2 uses a different naming convention for blocks and references compared to Magento 1. Always refer to the official documentation or theme guide when making layout changes.
Conclusion
In summary, displaying top-links in your footer required a careful addition of the top.links block to your theme’s main layout file (default.xml). By following these steps and ensuring you’re working with an up-to-date version of Magento 2, you should be able to display any custom blocks or links in your footer.
For more advanced customizations or if you encounter other issues, I recommend checking out the resources at Laravel Company. They provide comprehensive guides and tutorials for working with Laravel, which shares many principles with Magento when it comes to layout rendering.