1

First, sorry for my mistakes, I am a new Magento developer. So I made a litle module to make some social share buttons (Facebook, twitter, etc...) and so I have to add in the head some meta (for Open Graph). I search everywhere on the internet and no answers are solving my problems.

How can I override the head ?

Everywhere I see "search for head.phtml..." but I search everywhere and I don't have any head.phtml.

I use Magento 2.2.5, and I have Infortis Ultimo theme.

1

1 Answer 1

3

1) Create a custom child theme that uses the ultimo theme as a parent:

app/code/design/frontend/YOURCOMPANY/YOURTHEME/theme.xml

<?xml version="1.0"?>
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
    <title>YOURCOMPANY YOURTHEME</title>
    <parent>Infortis/ultimo</parent>
</theme>

2) create app/code/design/frontend/YOURCOMPANY/YOURTHEME/registration.php file

<?php
    \Magento\Framework\Component\ComponentRegistrar::register(
        \Magento\Framework\Component\ComponentRegistrar::THEME,
        'frontend/YOURCOMPANY/YOURTHEME',
        __DIR__
    );

3) create app/design/frontend/YOURCOMPANY/YOURTHEME/Magento_Theme/layout/default_head_blocks.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <!-- favicons -->
        (...)

        <!-- Custom Metas -->
        <meta name="msapplication-TileColor" content="#ffffff"/>
        <meta name="msapplication-TileImage" content="icons/favicons/ms-icon-144x144.png"/>
        <meta name="theme-color" content="#ffffff"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"/>

        <!-- ADD YOUR OTHER METAS HERE .... -->
    </head>
</page>

4) Enable your custom theme in the admin area.

5) Read up for more info: https://devdocs.magento.com/guides/v2.2/frontend-dev-guide/themes/theme-inherit.html

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.