Magento – How to remove meta title from head in Magento 2

magento2meta-tagsmeta-title

I need to remove meta title from header in all pages.

<meta name="keywords" content="Oneplus One"/>
<meta name="robots" content="NOINDEX,NOFOLLOW"/>
<!-- I need to remove meta title -->
<meta name="title" content="Oneplus One"/>
<meta name="viewport" content="width=device-width/>
<meta name="format-detection" content="telephone=no"/>
<title>Oneplus One</title>

I have created module RemoveMetaTitle.

di.xml :

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Framework\View\Page\Config">
        <plugin name="unsetMetaTitle" type="Vendor\RemoveMetaTitle\Plugin\PageConfig\UnsetMetaTitle" sortOrder="9999"/>
    </type>
</config>

Plugin/PageConfig/UnsetMetaTitle.php :

namespace Vendor\RemoveMetaTitle\Plugin\PageConfig;

class UnsetMetaTitle
{
    public function afterGetMetaTitle($subject, $return)
    {
        return '';
    }
}

afterGetMetaTitle seems to be not even executed.

Best Answer

di.xml file

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Framework\View\Page\Config">
        <plugin name="unsetMetaTitle" type="Vendor\Module\Plugin\PageConfig\unsetMetaTitle" sortOrder="9999"/>
    </type>
</config>

PageConfig class

<?php
declare(strict_types = 1);
namespace Vendor\Module\Plugin\PageConfig;

class unsetMetaTitle
{
    public function afterGetMetaTitle($subject, string $return)
    {
        return '';
    }
}