2

I'm currently developing some Magento2 themes. I noticed that in Magento2 Meta Keywords are still added. I want to remove this meta keywords from all pages, does anyone know the proper way to achieve this?

I did find meta.phtml, but I think this file is not used on a product page. Also the file Product/View.php adds the keywords with this function:

$this->pageConfig->setKeywords($keyword);

but I don't think it would be the prober way to extend the _prepareLayout function, right?

Thanks.

8

I just had to do the same and decided to just add a plugin after the getKeywords Method of the page config which returns an empty string. works great

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

Plugin Class:

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

class RemoveMetaKeywords
{
    public function afterGetKeywords($subject, string $return)
    {
        return '';
    }
}
  • and the entire <meta name="keywords"... is gone. :) Thanks – JustinP Feb 6 at 23:22
1

Easy to remove or edit default meta keywords at admin configuration:

Store > Configuration > Design [General] - HTML Head
  • I want it removed from all pages, so also the category and product pages. When you create a product, the meta keywords will be automatically filled and added to the product page. So changing the default meta keywords will not do the trick. – Silvan Jan 6 '16 at 7:12

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.