How to Override Magento Theme Layout File

layoutmagento2overridestheme

I am a newbie to Magento 2.2.4 and i want to get bootstrap 4 css and my own js files.. As a first step trying to override the theme layout file.

I created a theme and enabled it successfully. (All js and css call are routed to my theme). The theme is inherited from magento-blank theme

Now i am trying to override the parent blank theme with my theme layout following this guide
https://devdocs.magento.com/guides/v2.2/frontend-dev-guide/layouts/layout-override.html

I am getting the following error :

Trying to override modular view file 'C:/xampp/htdocs/magento/app/design/frontend/TridentTechnominds/store/TridentTechnominds_Theme/layout/override/theme/magento/blank/default_head_blocks.xml'
for theme 'magento/blank', which is not ancestor of theme
'TridentTechnominds/store'

I tried all methods like :

  1. theme/Magento/theme-frontend-blank/default_head_blocks.xml => getting error over here
  2. theme/Magento/frontend-blank/default_head_blocks.xml
  3. theme/Magento/blank/default_head_blocks.xml => getting error over here
  4. theme/magento/theme-frontend-blank/default_head_blocks.xml

Kindly guide me the right folder structure. I have been just making and googling for 6 hours now.

Attached is the folder structure…enter image description here

Update 1:

My mistake in naming convention of the folder. The blue underlined folder name was changed.

Even then, the trident.css is getting loaded from position black underlined i.e. under layout folder.

If i take it inside theme/magento/blank it doesnt work.
Note: I tried Magento as foldername too.

Attaching the updated folder structure.
enter image description here

Best Answer

To override layout from parent theme, here in your case default_head_blocks.xml from Magento/blank :

app/design/frontend/{Vendor}/{themeName}/Magento_Theme/layout/override/theme/Magento/blank/default_head_blocks.xml

More information in Magento DevDocs.