3

I have issue any time in meta="title" and both are display all Pages So i have Remove Meta="Title" Using File Override In Magento Core Module

3

Finally I got solution. Please check below code

Create di.xml File in your Custom module

<preference for="Magento\Framework\View\Page\Config\Renderer" type="Module\Demo\View\Page\Config\Rendererfile" />

Rendererfile.php

<?php

    namespace Module\Demo\View\Page\Config;

    use Magento\Framework\Exception\LocalizedException;
    use Magento\Framework\View\Asset\GroupedCollection;
    use Magento\Framework\View\Page\Config;

    class Rendererfile extends \Magento\Framework\View\Page\Config\Renderer
    {

        protected function getMetadataTemplate($name)
        {
            if (strpos($name, 'og:') === 0) {
                return '<meta property="' . $name . '" content="%content"/>' . "\n";
            }

            switch ($name) {
                case Config::META_CHARSET:
                    $metadataTemplate = '<meta charset="%content"/>' . "\n";
                    break;

                case Config::META_CONTENT_TYPE:
                    $metadataTemplate = '<meta http-equiv="Content-Type" content="%content"/>' . "\n";
                    break;

                case Config::META_X_UI_COMPATIBLE:
                    $metadataTemplate = '<meta http-equiv="X-UA-Compatible" content="%content"/>' . "\n";
                    break;

                case Config::META_MEDIA_TYPE:
                    $metadataTemplate = false;
                    break;

                default:
                if ($name === 'title') {
                     $metadataTemplate = '';
                }
                else
                {

                    $metadataTemplate = '<meta name="%name" content="%content"/>' . "\n";
                }
                    break;
            }
            return $metadataTemplate;
        }

    }
1

Create your plugin extension and add below code on 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>

Create unsetMetaTitle.php file into Plugin\PageConfig folder

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

class unsetMetaTitle
{
    public function afterGetMetaTitle($subject, string $return)
    {
        return '';
    }
}
  • It's not working in magento2.3.1 so please refer my above answer – hirokapuriya Jun 25 at 11:11

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.