Categories
Development

HOWTO: Fix “Keyword title is not registered” error in Joomla 3.0

If you’re working with Joomla using an HTML5 template and you try and validate your site using the [W3C Markup Validation Service](http://validator.w3.org), you may find yourself hit with the following validation error:

*Line 7, Column 44*: **Bad value title for attribute name on element meta: Keyword title is not registered.**

  <meta name="title" content="Who We Are" />
Syntax of metadata name:
A metadata name listed in the HTML specification or listed in the WHATWG wiki. You can register metadata names on the WHATWG wiki yourself.

The **title** meta keyword is a carryover from older versions of Joomla (pre-HTML5), back when the HTML specification did not restrict meta keywords as they do now. While it’s true that the error notice provides instructions on how to register a metadata name yourself, there is a quick fix that gets your site to validate and avoids involvement in deliberations over an emerging spec, and it can be applied **without** modifying Joomla core files.

To fix the error, simply add the following line to the opening PHP code block in your template’s **index.php**, right before the closing tag:

// remove “title” metadata keyword because it breaks HTML5 validation
$doc->setMetaData(‘title’, FALSE);

This line simply unsets the keyword so that the meta tag will not be rendered by the template engine. It assumes that your template code has already set the `$doc` variable using `JFactory::getDocument()`. If your Document object is assigned to a different variable, use that instead.