Feb 04 2013

How to add a custom meta tag in Joomla

Category: HomeFarhan Sabir @ 00:05

After searching google on the subject, i couldnt really find much. so i explored the contents. Here is the procedure to add a custom meta tag to your joomla website. I needed it mainly to do the site verification of a few alias domains.

Edit the file includes/application.php

case 'html':
// Get language
$lang_code = JFactory::getLanguage()->getTag();
$languages = JLanguageHelper::getLanguages('lang_code');

// Set metadata
if (isset($languages[$lang_code]) && $languages[$lang_code]->metakey) {
$document->setMetaData('keywords', $languages[$lang_code]->metakey);
} else {
$document->setMetaData('keywords', $this->getCfg('MetaKeys'));
$document->setMetaData('rights', $this->getCfg('MetaRights'));
$document->setMetaData('language', $lang_code);
$document->setMetaData('google-site-verification', "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1");
$document->setMetaData('google-site-verification', "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx2");
if ($router->getMode() == JROUTER_MODE_SEF) {

Say you want to set google-site-verification, and google provides you the following code:

(I have removed the actual code)

so we will write $document->setMetaData(“**thekey**”, “**thevalue**); i.e.,

$document->setMetaData('google-site-verification', "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1");

Leave a Reply