How to override in phtml file in Magento 2

4.8k Views Asked by At

In Magento 2, I have create new theme and copy header.phtml file from vendor/magento/module-theme/view/frontend/templates/html folder and paste in app/design/frontend/mage_vender/sample(theme)/module-theme/template/html/header.phtml file. And i am trying to change in header.phtml file but changes not showing. Please can anyone tell me what step i forgot ? I am using magento 2.1.3 Thank you

1

There are 1 best solutions below

4
On BEST ANSWER

I'll post the answer for both phtml and html files.

Overriding phtml files

For example if you want to override site_name/vendor/magento/module-checkout/view/frontend/templates/cart/shipping.phtml, you will need to put it under /site_name/app/design/frontend/ThemeName/default/Magento_Checkout/templates/cart/shipping.phtml

Overriding (KO) html files

For example if you want to override /site_name/vendor/magento/module-checkout/view/frontend/web/template/summary/item/details.html, you will need to put it under/site_name/app/design/frontend/ThemeName/default/Magento_Checkout/web/template/summary/cart-items.html

Now html pages can be a hassle, you need to make sure the caches from your browser are cleared. If you're using the latest google chrome you can inspect element go to network tab and then tick disable caches, reload the page. Reason for this is that HTML pages are more cacheable. If this does not work clear you pub/static/frontend folder.