If you use a plain joomla 2.5.x / 3.0.* (for 3.5.* see update below) installation and check the generated source code you can see that the CMS pushed every header line generated by the <jdoc:include type=”head” /> onto a new line. You wish to change that so that your source is more “compressed”. How can you do that?
Joomla 2.5.*:
1.) Copy the file “/libraries/joomla/document/html/renderer/head.php” to your template root folder and name it rendererheader.php.
2.) Edit your index.php and add the following:
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'rendererheader.php';
Now you can change the output from <jdoc:include type=”head” />. To do that you need to change the source code in the rendererheader.php file. Now change the buffer variable and remove the $tab and $lnEnd variables.
Here is a short example the old line:
$buffer .= $tab . $custom . $lnEnd;
must be changed to:
$buffer .= $custom;
Â
Update for Joomla 3.5.*:
Since joomla3.5 the class JDocumentRendererHead is deprecated and replaced with JDocumentRendererHtmlHead. So if you wish to use your Joomla 2.5/3.0 template with Joomla 3.5 you need to modifize yourrendererheader.php file and change JDocumentRendererHead to JDocumentRendererHtmlHead
Â
Update for Joomla 3.8.* / 3.9.*:
With joomla 3.8 the /libraries/joomla/document/html/renderer/head.php do no longer exists. Therefore you need the \libraries\src\Document\Renderer\Html\HeadRenderer.php. So to overwrite the header information in Joomla 3.8.x do the following:
1.) Copy the file “\libraries\src\Document\Renderer\Html\HeadRenderer.php” to your template root folder and name it rendererheader.php.
2.) Edit your index.php and add the following:
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'rendererheader.php';
Now you can change the output from <jdoc:include type=”head” />. To do that you need to change the source code in the rendererheader.php file. Now change the buffer variable and remove the $tab and $lnEnd variables.
Here is a short example the old line:
$buffer .= $tab . '<base href="' . $base . '" />' . $lnEnd;
must be changed to:
$buffer .='<base href="' . $base . '" />';
If you wish to remove the generator meta tag:
<meta name="generator" content="Joomla! - Open Source Content Management" />
Then you need to edit your rendererheader.php you created before and search for the following line and edit them so that will look like:
// Don't add empty generators
//$generator = $document->getGenerator();
//if ($generator)
//{
//$buffer .= $tab . '<meta name="generator" content="' . htmlspecialchars($generator, ENT_COMPAT, 'UTF-8') . '" />' . $lnEnd;
//}
Â
Cross reference:
edit the output of jdoc:include type=head via renderer/head.php