2

It seems like having a keywords meta tag in your head is nowadays bad for SEO. Does anyone know how to remove the keywords meta tag from the head in Magento 2 in a professional way?

1

Create a module with name STech_Removekeywords and create the files like below steps:

Step 1: Create registration.php under:

app/code/STech/Removekeywords/registration.php

with below content:

<?php

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'STech_Removekeywords',
    __DIR__
);

Step 2: Create module.xml under:

app/code/STech/Removekeywords/etc/module.xml

with below content:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
    <module name="STech_Removekeywords" setup_version="0.0.1">
        <sequence>
            <module name="Magento_Backend"/>
            <module name="Magento_Sales"/>
            <module name="Magento_Catalog"/>
        </sequence>
    </module>
</config>

Step 3: Create di.xml under:

app/code/STech/Removekeywords/etc/di.xml

with below content:

<?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="removeMetaKeywords" type="STech\Removekeywords\Plugin\PageConfig\RemoveMetaKeywords" sortOrder="9999"/>
    </type>
</config>

Step 4: Create RemoveMetaKeywords.php under:

app/code/STech/Removekeywords/Plugin/PageConfig/RemoveMetaKeywords.php

with below content:

<?php
namespace STech\Removekeywords\Plugin\PageConfig;

class RemoveMetaKeywords
{
    public function afterGetKeywords($subject, string $return)
    {
        return '';
    }
}

Run setup upgrade, di compile and other required commands and test.

| improve this answer | |
  • Did you put downvote? – Sukumar Gorai Sep 17 '18 at 12:46
  • I've put upvote of course – Joris Sep 18 '18 at 11:40
-1

Simple just remove the meta tag from the vendor\magento\module-cms\view\frontend\templates\meta.phtml Or app\design\frontend\/\Magento_Cms\templates\meta.phtml

<?php if ($pageData->getPageMetaKeywords()): ?>
       <meta name="keywords" content="<?= /* @noEscape */ $pageData->getPageMetaKeywords() ?>"/>
<?php endif; ?>
| improve this answer | |

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.