How to override /var/www/html/magento2/vendor/magento/module-checkout/view/frontend/web/template/minicart/content.html file in our custom theme?
5 Answers
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.
- 1Trying to override homepage. But not workingJackson– Jackson2016-09-27 10:28:36 +00:00Commented Sep 27, 2016 at 10:28
- which page, please give me pathRakesh Jesadiya– Rakesh Jesadiya2016-09-27 10:34:24 +00:00Commented Sep 27, 2016 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 magento.stackexchange.com/questions/138223/…Jackson– Jackson2016-09-27 10:35:09 +00:00Commented Sep 27, 2016 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-lumaRakesh Jesadiya– Rakesh Jesadiya2016-09-27 10:36:26 +00:00Commented Sep 27, 2016 at 10:36
- I would like to override Luma Theme Cannot do that?Jackson– Jackson2016-09-27 10:37:06 +00:00Commented Sep 27, 2016 at 10:37
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.
- hey. when i override
content.htmlthis way then why its give me blank? minicart.Chirag Prajapati– Chirag Prajapati2016-11-18 07:51:22 +00:00Commented Nov 18, 2016 at 7:51 - There is this file
Vendor_ModuleName/template/minicart/content.htmlinpub/static?Khoa Truong– Khoa Truong2016-11-18 07:53:57 +00:00Commented Nov 18, 2016 at 7:53 - yes.. and also my config code in
requirejs-config.jsis availbaleChirag Prajapati– Chirag Prajapati2016-11-18 07:58:00 +00:00Commented Nov 18, 2016 at 7:58 - when i see console, its also taking my file instead of core. but don't know why its display nothing.Chirag Prajapati– Chirag Prajapati2016-11-18 07:59:39 +00:00Commented Nov 18, 2016 at 7:59
- Tried to clear your Browser Cache?Khoa Truong– Khoa Truong2016-11-18 08:02:35 +00:00Commented Nov 18, 2016 at 8:02
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.
- i have try same you suggest this but not works.Rakesh Jesadiya– Rakesh Jesadiya2016-01-09 11:33:42 +00:00Commented Jan 9, 2016 at 11:33
- Did you deploy static files? And cleared cache?Silvan– Silvan2016-01-09 11:43:43 +00:00Commented Jan 9, 2016 at 11:43
- 1yes, its working fine after clear static files and it will auto generate new file on next page load.Rakesh Jesadiya– Rakesh Jesadiya2016-01-09 11:50:29 +00:00Commented Jan 9, 2016 at 11:50
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
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 - you shouldn't modify stuff in pub/static.. it will be overridden by static deploy command anyway...OZZIE– OZZIE2018-04-24 09:36:07 +00:00Commented Apr 24, 2018 at 9:36