2

I am trying to override HTML template in my custom module. I am working on Magento ver 2.2.2

Vendor/Moule/view/frontend, I have created a requirejs-config.js file:

    var config = {
    map: {
        '*': {
            'Magento_Checkout/template/minicart/content.html': 'Vendor_Module/template/minicart/content.html',
            'Magento_Checkout/template/minicart/item/default.html': 'Vendor_Module/template/minicart/item/default.html'
        }
    }
};

Copied custom file minicart\content.html to

Vendor\Module\view\frontend\web\template\minicart\content.html and

copied minicart/item/default.html to

Vendor\Module\view\frontend\web\template\minicart\item\default.html

Run below commands:

php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
php bin/magento cache:clean

After doing this, my default files disappear and my files are not showing, please let me know if I am doing something wrong.Thanks in advance :)

5
  • Check with private window or clear browser cache to see changes of HTML and JS files Commented Jan 10, 2018 at 5:56
  • Yes, I have cleared browser cache but unable to see any changes.
    – user00247
    Commented Jan 10, 2018 at 6:27
  • Is I am doing something wrong or you can suggest any other method to override HTML template from a custom module?
    – user00247
    Commented Jan 10, 2018 at 6:27
  • Open Inspect element and go to network tab and find/open content.html and check your changes Commented Jan 10, 2018 at 6:36
  • Yr Welcome -- :) Commented Jan 10, 2018 at 10:03

2 Answers 2

2

Here is the simple method to show changes of HTML and JS files without clearing the cache of the browser.

Right click on page and inspect element and open network tab. Now Double click on Html or Js file which you edited. And just full refresh html or js page in new tab.

Now Done. You can see changes on next refresh page.

Screenshot:

enter image description here

0
1

Try following code:

  1. app/code/[VendorName]/[ModuleName]/view/frontend/requirejs-config.js
var config = {
    paths: {
        'Magento_Checkout/template/minicart/content': '[VendorName]_[ModuleName]/template/minicart/content',
        'Magento_Checkout/template/minicart/item/default': '[VendorName]_[ModuleName]/template/minicart/item/default'
    }
};
  1. app/code/[VendorName]/[ModuleName]/view/frontend/web/template/minicart/content.html
  2. app/code/[VendorName]/[ModuleName]/view/frontend/web/template/minicart/item/default.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.