I'm learning magento 2 from the link. In this article i'm unable to identify layout and template files even after reading locate template. Please help me on how to identify layout and template in the example given by magento link

  • I was searching in the magento blank theme, now i changed the theme to luma theme and I could follow the link provided by magento2 – prasad maganti Jul 29 '15 at 10:44
  • If your block has absolute positioning or have float style - you will not see proper hints – zhartaunik Jul 31 '15 at 13:03

There is no template for the top links.
There can be one, but by default there isn't one.
The top links block is declared in app/code/Magento/Theme/view/frontend/layout/default.xml

<block class="Magento\Framework\View\Element\Html\Links" name="top.links">
          <argument name="css_class" xsi:type="string">header links</argument>

So the block in an instance of Magento\Framework\View\Element\Html\Links.
If you look in the _toHtml method of the block you will find this:

protected function _toHtml()
    if (false != $this->getTemplate()) {
        return parent::_toHtml();

    $html = '';
    if ($this->getLinks()) {
        $html = '<ul' . ($this->hasCssClass() ? ' class="' . $this->escapeHtml(
        ) . '"' : '') . '>';
        foreach ($this->getLinks() as $link) {
            $html .= $this->renderLink($link);
        $html .= '</ul>';

    return $html;

this means that if the block has a template assigned it will use that template. Otherwise it will be rendered as an ul element.

if you want to associate a template to it, you have to add this in one of your layout files:

<page ...>
         <referenceBlock name="top.links">
             <action method="setTemplate">
                <argument name="template" xsi:type="string">path/to/template.phtml</argument>

And there are a lot of layout files that add links to this top links block. Just search in your file for the text referenceBlock name="top.links" and you will find all of them.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.