Search code examples
magento

Add Meta Title, Meta Keyword and Meta Description In Custom Module


I'm new in magento. I just want to know how can I Add Meta Title, Meta Keyword and Meta Description in Custom Module.


Solution

  • There are two ways to set meta information:

    1. Please Insert this code in custom module layout.xml file.
    <reference name = "head">
       <action method = "setTitle"><title>Accessory</title></action>
       <action method = "setKeywords"><title>module, keywords</title></action>
       <action method = "setDescription"><title>Module Description</title></action>
    </reference>
    
    1. Please open your module block file from below mention location and set Meta Title/Keyword/Description

    app/code/local/namespace/yourmodule/block/yourmodule.php

    public function _prepareLayout() {        
        $head = $this->getLayout()->getBlock('head');
        $head->setTitle("Your Title");
        $head->setKeywords("your, keywords, anything");
        $head->setDescription("Your Description");
        return parent::_prepareLayout();
    }