13

How to override /var/www/html/magento2/vendor/magento/module-checkout/view/frontend/web/template/minicart/content.html file in our custom theme?

Rakesh Jesadiya
  • 42,221
  • 18
  • 132
  • 183

5 Answers5

19

first we have to override web/template files to our magento theme file, in my case content.html

Magento_Checkout/web/template/minicart/content.html

After changes in content.html file, we have to deploy static file using command php bin/magento setup:static-content:deploy

OR

You have to delete content.html(i have to change content in this file) file from pub/static/frontend/Magento/buytea/en_US/Magento_Checkout/template/minicart and reload page again.

Changes are applied.

Rakesh Jesadiya
  • 42,221
  • 18
  • 132
  • 183
  • 1
    Trying to override homepage. But not working – Jackson Sep 27 '16 at 10:28
  • which page, please give me path – Rakesh Jesadiya Sep 27 '16 at 10:34
  • I have below folder structure

    magento2 |_ app |_ design |_ frontend |_ Magento |_luma |_Magento_Theme |_templates |_root.phtml composer.json registration.php theme.xml & refer http://magento.stackexchange.com/questions/138223/how-to-override-html-file-in-magento-2-1/

    – Jackson Sep 27 '16 at 10:35
  • you have to defined your custom theme, inside luma its not working, if you want to changes inside luma theme then go to your vendor/magento/theme-frontend-luma – Rakesh Jesadiya Sep 27 '16 at 10:36
  • I would like to override Luma Theme Cannot do that? – Jackson Sep 27 '16 at 10:37
  • you have to create your custom theme and set luma theme as parent. you directly not defined luma theme as defined you in above query – Rakesh Jesadiya Sep 27 '16 at 10:38
  • Is there any guide or link you can provide it will be really helpful. Because i exactly don't know how to do it – Jackson Sep 27 '16 at 10:39
  • you can refer this post for override luma theme, http://magento.stackexchange.com/questions/136289/how-to-add-banner-or-slider-in-magento-2-1-1-home-page-and-how-to-create-custom/136292#136292 – Rakesh Jesadiya Sep 27 '16 at 10:46
  • I tried running php bin/magento setup:static-content:deploy -f after creating the new file in my custom theme, but it never showed my changes. After manually deleting the file in pub/static it then showed up – iamface Aug 23 '18 at 22:20
17

There is another way. We should know that we can override the html template via RequireJS. We don't need to create a custom theme. In your custom module, create a requirejs-config.js:

app/code/{Vendor}/{Module_Name}/view/frontend/requirejs-config.js

var config = {
    map: {
        '*': {
            'Magento_Checkout/template/minicart/content.html':
                'Vendor_ModuleName/template/minicart/content.html'
        }
    }
};

A more explain we can read more here.

Khoa TruongDinh
  • 32,054
  • 11
  • 88
  • 155
7

You can override this by adding this folder to your theme:

Magento_Checkout/web/template/minicart

In this folder you can create the content.html file. After a change made in this file make sure you flush your browser cache to see the changes.

Silvan
  • 1,347
  • 6
  • 33
  • 55
1

Although Khoa TruongDinh's answer was really helpful, there are some details missing so here is a full example:

Working minicart example, copy the html template to:

[theme_path]/Magento_Theme/web/template/minicart/content.html

and in themes requirejs-config.js =>

var config = {
    "map": {
        "*": {
            'Magento_Checkout/template/minicart/content.html': 'Magento_Theme/template/minicart/content.html'
        }
    }
};

See also core bug: https://github.com/magento/magento2/issues/5832

OZZIE
  • 552
  • 7
  • 13
-1

Open file for modifying minicart contents:

/app/design/frontend/your_theme/Theme/Magento_Checkout/web/template/minicart/content.html

Open file for modifying minicart product contents :

/app/design/frontend/Eglo/Theme/Magento_Checkout/web/template/minicart/item/default.html

After modification, You have to deploy the theme using bin/magento setup:static-content:deploythen it will show.

If modification is not populated then modify tempaltes in below directory for showing runtime changes:

/pub/static/frontend/Your_theme/Theme/en_US/Magento_Checkout/template/minicart
Chirag Prajapati
  • 2,922
  • 2
  • 18
  • 42
Abhinav Singh
  • 2,592
  • 15
  • 14
  • you shouldn't modify stuff in pub/static.. it will be overridden by static deploy command anyway... – OZZIE Apr 24 '18 at 09:36