cancel
Showing results for 
Search instead for 
Did you mean: 

How to remove meta tags from "specific CMS page" in magento2 ?

How to remove meta tags from "specific CMS page" in magento2 ?

Hello Community, 

I am working on Magento 2.2 . The requirement is I want to remove all the meta data (meta keywords, meta description etc.) From one of our CMS page. Is there any simple way to remove that ? 
Rest all pages should have a meta data as it is... only requirement is need to remove it from one particular page. 

Can anyone help me to resolve this ? 

3 REPLIES 3

Re: How to remove meta tags from "specific CMS page" in magento2 ?

Hi @maratheprash,

You can simply remove from the magento admin for the cms page.

Go to
Admin -> Content-> CMS -> Pages

Edit your page, in Meta SEO TAB, remove meta keywords, title, description etc.

For more info
https://docs.magento.com/m2/ce/user_guide/cms/page-add.html

I hope it will help you!

Re: How to remove meta tags from "specific CMS page" in magento2 ?

Hello @maratheprash ,

If you just simply want to remove meta title, meta description and meta keywords. Then simply go with @Vimal Kumar suggestion.

But If you want to remove all the meta tag completely, you can achieve this by plugin. I have created a module for this hope this will help:

 

Create Vendor/RemoveMetaTag/registration.php

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Vendor_RemoveMetaTag',
    __DIR__
);

 

Create Vendor/RemoveMetaTag/etc/module.xml

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Vendor_RemoveMetaTag" />
</config>

 

Create Vendor/RemoveMetaTag/etc/frontend/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="removeMetaTag" type="Vendor\RemoveMetaTag\Plugin\PageConfig\RemoveMetaTag" sortOrder="1000"/>
    </type>
</config>

Then lastly create you plugin in

 

Vendor/RemoveMetaTag/Plugin/PageConfig/RemoveMetaKeywords.php

<?php
namespace Vtn\RemoveMetaTag\Plugin\PageConfig;

class RemoveMetaTag
{
    public function __construct(
        \Magento\Framework\App\Request\Http $request
    )
    {        
        $this->request = $request;
    }
    
    public function afterGetMetadata($subject, array $metaData)
    {
        $pathInfo = $this->request->getPathInfo();
        $pageId = str_replace("/cms/page/view/page_id/","",$pathInfo);
        
        if ($pageId == "your_page_id") {
            return [];
        }
        return $metaData;
    }
}

For you page id please refer below image:

Screenshot from 2019-08-22 13-46-34.png

I hope this will work for you. If you still have any query please let me know.

If it helps you, please accept it as solution and give kudos.

Regards.

Re: How to remove meta tags from "specific CMS page" in magento2 ?

Hi, 

The above solution is not resolving my problem. I am not at all getting debugger inside that plugin method. 

 

Can you please help me on it?