Magento 2.x – How to add a customer myaccount link and its corresponding page


So, in some cases we will need to add a link in the customer my account frontend section. To do so, we should perform the following basic steps:

  • The first and easiest part, is adding the link, to do so, create the following layout file app/code/Vendor/Module/view/frontend/layout/default.xml
  • Then, we will need this custom controller, to process the request once the link is clicked, so we will need a couple of things:
    • app/code/Vendor/Module/etc/frontend/routes.xml
    • app/code/Vendor/Module/Controller/Customthing/Index.php
    • app/code/Vendor/Module/view/frontend/layout/mymodule_customthing_index.xml
    •  app/code/Vendor/Module/view/frontend/templates/customer/custom_thing.phtml
  • Afterwards, you will need to perform those steps on your CLI:
  • Now make a try, log in the frontend with a customer, and you will see something like this on your myaccount section

Happy coding!