简体   繁体   中英

How to edit the Joomla template header?

Basically, I am just trying to slightly modify my Joomla template.

There is a line of code within the <head> of my template that is obviously grabbing things such as meta description, meta keywords and title tags.

Here is the code <jdoc:include type="head" />

I would like to know where this code is located since I would like my title tag above both my meta description and meta keywords .

Is this possible?

Try this,

Its not recommended editing core files.

You can find the meta and title section of the Joomla sites.

libraries\joomla\document\html\renderer\head.php

contains a function fetchHead()

Hope its helped...

You could copy the header.php to your template folder (name it head_renderer.php) and inside the index.php from your template reference the new header.php via:

require_once dirname( FILE ) . DIRECTORY_SEPARATOR . 'head_renderer.php'; // our modifized renderer for the Joomla header

then you do not fully "edit the core files". However its a hack and not a template overwrite. But via this approach you can update joomla and do not need to check if your changed header.php is changed.

A better howto can be found here .

You can read the header values with...

$doc = JFactory::getDocument();
$head_data = $doc->getHeadData();

...then set new values, or update the existing values with code like...

$head_data["metaTags"]["name"]["twitter:title"] = $head_data["title"];

...then write it back with...

$doc->setHeadData($head_data);

See also https://stackoverflow.com/a/71410700/789137

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM