1

I want to include a new css file styles.css. Steps I've taken:

1) switch to developer mode (magento deploy:mode:set developer);

2) edit dev/tools/grunt/configs/themes.js and include my theme with my new file styles:

my_theme: {
        area: 'frontend',
        name: 'My_company/my_theme',
        locale: 'en_GB',
        files: [
            'css/styles',
        ],
        dsl: 'less'
    },

3) In My_company/my_theme/Magento_Theme/layout/default_head_blocks.xml I add it like this <css src="css/styles.css" />

4) In My_company/my_theme/web/css/syles.less I add @import 'source/_theme.less'; and then have My_company/my_theme/web/css/_theme.less with different variables.

5) Run grunt clean, grunt exec, grunt less and it went along fine without errors:

Running "less:my_theme" (less) task
File pub/static/frontend/My_company/my_theme/en_GB/css/styles.css created: 435 B → 992 B

Tried removing everything from the var folder and from pub/static except the .htaccess. Cleared cache, regenerating static folder magento setup:static-content:deploy. Checked in the admin that my theme is selected in web > design. Reindexed.

In view page source magento is still looking for pub/static/frontend/My_company/my_theme/en_GB/css/styles-m.css (which returns a 404) and not including pub/static/frontend/My_company/my_theme/en_GB/css/styles.css

Where can I look next?

Thanks!

0

Always check the logs. In system.log I found this error:

Cache file with merged layout: LAYOUT_frontend_STORE1_46f1b068ec7ccf4878f9284dd1137afd1: Please correct the XML data and try again

Theme layout update file '/var/www/app/design/frontend/My_company/my_theme/Magento_Theme/layout/default_head_blocks.xml' is not valid.

It would have been great if developer mode broke the page highlighting the xml error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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