4

(heavily modified the question for simplicity and clarity)

As a test case, I created <custom-theme>/Magento_Theme/layout/default_head_blocks.xml. Creating and modifying this file, according to the docs, should affect every page.

In my extended default_head_blocks.xml I added a bogus JS, just to see what pages it will be added to.

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <script src="js/test-file.js"/>
    </head>
</page>

I can see test-file.js on category and CMS pages, but not on a product page.

I can't get any layout updates to affect the product page. The product page has the inherited theme Magento Blank, plus my site logo, located in <theme-dir>/web/imges/logo.svg.

Any guidance on this issue would be appreciated.

3
  • Please review the documentation and let us know if it's helpful or not. Commented Jan 16, 2016 at 15:14
  • Hi, if you'll provide your layout XML here, we can help you. Thanks Commented Jan 18, 2016 at 15:56
  • Take a theme based on Magento Blank, and create app/design/frontend/Vendor/theme/Magento_Catalog/layout/catalog_product_view.xml and create <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <move element="page.main.title" destination="product.info.main" after="-"/> </body> </page> and nothing changes
    – andyjv
    Commented Jan 18, 2016 at 16:19

3 Answers 3

0

There was similar issue with a custom layout file not being applied: https://github.com/magento/magento2/issues/2996

One of the community members solved an issue with custom layout file not being applied by changing line endings to unix and encoding to utf8 in his custom layout.

1
  • Great suggestion, but best I can tell, my files are utf-8 encoded and use unix line endings. I am developing on MAMP.
    – andyjv
    Commented Jan 22, 2016 at 19:16
0

Just create the composer.json in your theme if not created yet.

{
    "name": "vendor_name/theme_name",
    "description": "N/A",
    "require": {
        "php": "~5.5.0|~5.6.0|~7.0.0",
        "magento/theme-frontend-blank": "100.0.*",
        "magento/framework": "100.0.*"
    },
    "type": "magento2-theme",
    "version": "2.2.1",
    "license": [
        "OSL-3.0",
        "AFL-3.0"
    ],
    "autoload": {
        "files": [
            "registration.php"
        ]
    }
}

Then, run below command

php bin/magento setup:upgrade

Hope it helps you!

-1

Product Page layout in magento2 have to set from product. Edit the product from backend and set it to 1 column.

Edit the product

0

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.