3

I've checked in both the admin area configuration > design > HTML Head.

The current title, description and keywords currently don't come from here although in the backend file head.phtml the code written pulls in these Fields I believe.

(I'm still learning Magento)

Here is the code in the previous mentioned file

<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    design
 * @package     base_default
 * @copyright   Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<meta http-equiv="Content-Type" content="<?php echo $this->getContentType() ?>" />
<title><?php echo $this->getTitle() ?></title>
<meta name="description" content="<?php echo htmlspecialchars($this->getDescription()) ?>" />
<meta name="keywords" content="<?php echo htmlspecialchars($this->getKeywords()) ?>" />
<meta name="robots" content="<?php echo htmlspecialchars($this->getRobots()) ?>" />
<link rel="icon" href="<?php echo $this->getFaviconFile(); ?>" type="image/x-icon" />
<link rel="shortcut icon" href="<?php echo $this->getFaviconFile(); ?>" type="image/x-icon" />
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,600,800,700' rel='stylesheet' type='text/css' />
<script src="<?php echo $this->getSkinUrl('js/jquery-1.7.min.js') ?>" type="text/javascript"></script>
<script type="text/javascript" src="<?php echo $this->getSkinUrl('js/scripts.js') ?>"></script>
<script type="text/javascript" src="<?php echo $this->getSkinUrl('js/jquery.prettyPhoto.js') ?>"></script>
<script type="text/javascript" src="<?php echo $this->getSkinUrl('js/jquery.color.js') ?>"></script>
<!--[if lt IE 7]>
<script type="text/javascript">
//<![CDATA[
    var BLANK_URL = '<?php echo $this->helper('core/js')->getJsUrl('blank.html') ?>';
    var BLANK_IMG = '<?php echo $this->helper('core/js')->getJsUrl('spacer.gif') ?>';
//]]>
</script>
<![endif]-->
<!--[if lt IE 8]>
<div style=' clear: both; text-align:center; position: relative;'>
 <a href="http://windows.microsoft.com/en-US/internet-explorer/products/ie/home?ocid=ie6_countdown_bannercode"><img src="http://storage.ie6countdown.com/assets/100/images/banners/warning_bar_0000_us.jpg" border="0" height="42" width="820" alt="You are using an outdated browser. For a faster, safer browsing experience, upgrade for free today." /></a>
</div>
<![endif]--> 
<!--[if IE]>
    <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />
    <link href='http://fonts.googleapis.com/css?family=Open+Sans:600' rel='stylesheet' type='text/css' />
    <link href='http://fonts.googleapis.com/css?family=Open+Sans:700' rel='stylesheet' type='text/css' />
    <link href='http://fonts.googleapis.com/css?family=Open+Sans:800' rel='stylesheet' type='text/css' />
<![endif]-->
<?php echo $this->getCssJsHtml() ?>
<?php echo $this->getChildHtml() ?>
<?php echo $this->helper('core/js')->getTranslatorScript() ?>
<?php echo $this->getIncludes() ?>

I tried commenting out line 29 <meta name="description" content="<?php echo htmlspecialchars($this->getDescription()) ?>" /> This makes the meta description vanish so I know this is the correct file generating the text but I can't figure out where I edit the input fields?

Thanks for any help.

5

If There is a CMS page then go to the CMS >> Page >> Add/ edit you find the META tab in that you can add Keywords and Description. and title will come form Page Information >> Page Title.

If you load the product then This will load from the Catalog >> Manage Products >> you find in Meta Information Tab in that.

Magento Load this data Dynamically.

Hope you got the Proper Answers.

  • Thankyou - this was the exact solution @Keyul Shah – dannyw24 Jan 17 '14 at 14:14
  • @dannyw24 You welcome :) – Keyul Shah Jan 17 '14 at 14:15
11

The meta data is different from page to page.
For example, in the product page the meta data comes from the Meta title, Meta description and Meta keywords attributes of the products you are viewing. The same goes for categories and CMS pages.
These values can be set from the layout file for any page like this:

<page_handle_here>
    <reference name="head">
        <action method="setTitle" translate="title"><title>Meta title here</title></action>
        <action method="setDescription" translate="description"><description>Meta description here</description></action>
        <action method="setKeywords" translate="keywords"><keywords>Meta keywords here</keywords></action>
    </reference>
</page_handle_here>

or from the controller action specific for the page you are viewing like this after calling $this->loadLayout():

$head = $this->getLayout()->getBlock('head');
if ($head){
    $head->setTitle($this->__('Meta title here'));
    $head->setDescription($this->__('Meta description here'));
    $head->setKeywords($this->__('Meta keywords here'));
}

If the above cases do not apply for your page then the default values will be used. The default values can be found in System->Configuration->Design->HTMl Head. They are called Default Title, Default Description, Default Keywords.
These default values can be different on different store views.

  • This is a brilliant Answer however, the other answer actually led me to the solution can't believe I over looked this. – dannyw24 Jan 17 '14 at 14:14
  • @marius ... How do we check in xml layout that methods are available or exists like method="setTitle" , method="setDescription", method="setKeywords" and other methods in layout files..and what is the translate means and what is the use of it. .. thanks – MagentoBoy Jan 22 '14 at 14:47
  • 1
    @MagentoBoy you should be able to call those methods in any layout handle inside '<reference name="head">...'. The "head" block supports those methods. And translate="title" means that the text inside the tag <title> will be translated before it is used. – Marius Jan 22 '14 at 14:48
  • @Marius ...means all this methods are from block files?? like method use for head, root, content handle?? methods called from their block files for with they belongs to? – MagentoBoy Jan 22 '14 at 14:55
  • 1
    @MagentoBoy Yes. And be careful. you can even call methods that don't exist through the magic of __call. So anything that starts with set, get, uns, has can be used even if the method does not actually exist. – Marius Jan 22 '14 at 14:58

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.