In my Magento site, I want to move Welcome element which shows after login to the start of the top.links.

Currently it is showing in the end after login.

Without login:

enter image description here

With login:

enter image description here

Without login screen is fine and I want it in the same manner, but after login, it shows Welcome text at the end, whereas I want it in the starting.

I tried to add float: left to .welcome <li> but then it leave a space in the end when user is not loggedIn, as below:

enter image description here

Default Magento Blank looks like this: enter image description here

Please help!

  • You can try solution mentioned in the below link magento.stackexchange.com/questions/247546/… – Lokesh Naik Aug 4 at 14:08
  • Hi @LokeshNaik the solution given in that answer is to move the element, but I want to keep it in the same <ul> tag, but instead want to place it in the start of the list. – Prashant Aug 4 at 17:55
  • By default, magento places the welcome text at the start of the list for both logged-in and non-logged in users. It seems in your theme the blocks under <referenceBlock name="top.links"> ... </referenceBlock> has been overridden which may have altered the default sort order. – Lokesh Naik Aug 6 at 5:00
  • @LokeshNaik I think not, as Magento blank theme shows it in the middle, could you please check the screenshot I have attached in the question. – Prashant Aug 7 at 7:28
  • Oh yes! I was checking in default magento setup with luma theme. Check the answer below. – Lokesh Naik Aug 14 at 10:26

The default Magento\Theme\Block\Html\Header block which renders welcome text does not implement SortLinkInterface

You need to create a custom block which implements SortLinkInterface and pass the sortOrder as an argument to be able to sort it in comparison to other top links which implement the same interface.

Create below files in your module


<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <referenceBlock name="top.links">
            <block class="Vendorname\Modulename\Block\Html\Header" name="header" as="header" template="Magento_Theme::html/header.phtml">
                    <argument name="show_part" xsi:type="string">welcome</argument>
                    <argument name="sortOrder" xsi:type="number">220</argument>



namespace Vendorname\Modulename\Block\Html;

use Magento\Customer\Block\Account\SortLinkInterface;

class Header extends \Magento\Framework\View\Element\Html\Link implements SortLinkInterface
     * Retrieve welcome text
     * @return string
    public function getWelcome()
        if (empty($this->_data['welcome'])) {
            $this->_data['welcome'] = $this->_scopeConfig->getValue(
        return __($this->_data['welcome']);

     * {@inheritdoc}
     * @since 101.0.0
    public function getSortOrder()
        return $this->getData(self::SORT_ORDER);
| improve this answer | |

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.