I have 3 main categories in my stores. In order to give them a general color theme, I created 3 layouts file in app/design/Vendor/Theme/Magento_Theme/page_layout, they are named category_white , category_black , category_blue

Here is one of them (all 3 have same content actually)

<?xml version="1.0"?>
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">
    <update handle="1column"/>


This them gives me an additional class on my <body> and I use it in my CSS to give the proper colors.

When it comes to page building, my page configuration files always refer to layout="1column" then my 3 layouts inherit from it.

Now, I want as well to add the tag : <meta name="theme-color" content="#000000" /> (with of course a different content for each of the 3 categories), but I understood that I can not do it directly from the layout files I have to do it from the page configuration files (i.e. not from page_layout folder but from layout folder).

How can I target only one layout, I tried to have my default.xml as below and it does not work.

<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<page layout="category_white" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">

You can add as in HTML:

your Layout would look like-

<?xml version="1.0"?>
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">
    <meta name="description" content=" "/>
  • Don't forget the last slash in the meta tag. It will break the page otherwise – 07lodgeT Dec 17 '19 at 15:10
<reference name="head">
    <block type="core/text" name="blockname">
        <action method="setText">
                <![CDATA[<meta name="description" content=" "/>]]>
  • I do not see here how to target the 3 different layouts... – Memes Apr 19 '17 at 6:45
  • meta tag is a head param,it is not targeted to specific layouts – Visakh B Sujathan Apr 19 '17 at 6:58
  • Does not work when adding to Layout Update XML field on Magento 2.1.8 – Gediminas Jan 2 '18 at 18:12
  • This is Magento 1 code, not Magento 2 code. – Jisse Reitsma Mar 29 '19 at 14:22

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.