How to add a Logout link to the Customer Account Dashboard

To add a Logout link to the customer account dashboard you will need to change/create the layout file responsible for the customer account page.

That file is customer_account.xml and you should place it inside the Magento_Customer/layout folder in your custom theme with the following content:

# File app/design/frontend/<Theme_Vendor>/<Theme_Name>/Magento_Customer/layout/customer_account.xml

<?xml version="1.0"?> 
<page xmlns xsi="http://wwww3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/ete/page_configuration.xsd"> 
<body>
      <referenceBlock name="customer_account_navigation"> 
          <block class="Magento\Framework\View\Element\Html\Link\Current" name="customer-account-navagation-logout-link">
          <arguments>
               <argument name="path" xsi:type="string">customer/account/logout</argument>
               <argument name="label" xsi:type="string">Logout</argument>
          </arguments>
          </block>
     </referenceBlock>
 </body>
</page> 

Leave a Reply

Your email address will not be published. Required fields are marked *