In this post I am going to explain how to override login page template (login.phtml) in magento 2.
Here, I am using my custom module – Ht_Mymodule
First create xml file customer_account_login.xml and add below code snippet.
File Path: app/code/Ht/Mymodule/view/frontend/layout/customer_account_login.xml
<?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">
<body>
<referenceBlock name="customer_form_login">
<action method="setTemplate">
<argument name="template" xsi:type="string">Ht_Mymodule::form/login.phtml</argument>
</action>
</referenceBlock>
</body>
</page>Now add login.phtml file on below path.
File Path: app/code/Ht/Mymodule/view/frontend/templates/form/login.phtml
You can copy login.phtml file from Magento 2 default files and then write your changes.
You can find Magento 2 default login.phtml at below location.
vendor/magento/module-customer/view/frontend/templates/form/login.phtml
Thats it. Enjoy Magento 2!!
Write an article about ecommerce that help people to grow their ecommerce business. You’ll find best ecommerce guide, news, tips & more!


May 6, 2020 at 1:47 pm
Very informative post. Thank you!