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.

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

But how can I fix this error using joomla 2.5?
I got error: PHP Fatal error: Call to a member function setMetaData() on a non-object in /…/templates/theme760/index.php

When I add the above code to my index.php, I get a blank screen! I am using Joomla 3.3.3. Can you please elaborate more on where exactly we need to add the above line in index.php?

Thank you!

You want to modify {joomla root}/templates/{template name}/index.php and place this line at the end of the PHP code block at the top of the file.

I believe the title meta tag issue has been resolved in 3.3.3. Are you sure you even need this?

Thank you Nick for your quick response! I agree with you about the title meta tag issue being resolved in Joomla 3 but I am still getting the same error!

I have tried the code and now I am receiving the following message:

Line 3, Column 33: Non-space character in page trailer.
$doc->setMetaData(‘title’, FALSE);

Thank you!

Leave a Reply to Nick Bair Cancel reply

Your email address will not be published. Required fields are marked *