如何修改Joomla 网站中的标签?

发布于 2024-10-10 18:11:51 字数 79 浏览 5 评论 0原文

我的网站是在 joomla 1.5 中创建的。我想编辑我的网站页面标题标签。具体来说是 区域。我怎样才能做到这一点?

My website was created in joomla 1.5. I want to edit my website pages header tags. Specifically the <head> area. How can I do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

醉殇 2024-10-17 18:11:51

您可以在模板中自行添加 标签,并且可以在这些标签之间添加您想要的任何内容。在大多数 CMS 中,您可以完全控制 head 标签之间显示的内容。但是,使用 Joomla 时,您需要添加 。该标签的内容由 Joomla 自动填充,例如元数据(标题、描述等)。

您可以在控制面板“站点”>“全局元数据”中编辑全局元数据。全局配置。此外,在您创建的每篇文章上,您都可以单击侧面菜单来编辑该特定文章的元数据。

然而,有些事情你无法轻易改变。例如,在 joomla 标签 中,它还会加载 MooTools 等。这意味着如果您希望在页面底部加载 Mootools,那么您就不走运了。您可以手动编辑 /libraries/joomla/document/html/html.php 中的标签,但是每次更新系统时,您所做的任何更改都可能会被覆盖。所以你不想这样做。

You add the <head> tags yourself in your template and can add any content you wish between those tags. In most CMS's you have complete control in what appears between the head tags. With Joomla you are required to add <jdoc:include type="head" /> however. The content of that tag is automatically filled by Joomla such as meta data (title, description, etc.).

You can edit the global meta data in the control panel Site > Global Configuration. Also on each article you create you can click on the side menu to edit the meta data for that particular article.

However, there are some things you cannot easily change. Such as in that joomla tag <jdoc:include type="head" /> it also loads MooTools for instance. Which means if you wish to load Mootools at the foot of the page your out of luck. You could manually edit the tag in /libraries/joomla/document/html/html.php however whatever changes you make there may be overwritten every time you update the system. So you do not want to do that.

萧瑟寒风 2024-10-17 18:11:51

要修改标题部分,您需要访问管理仪表板。在扩展/主题中,然后在主题中选择您的默认主题。进入编辑器,选择文件 /html/com_content/default.php,您可以根据需要修改该文件。

在同一位置,您可以找到包含标头部分的文件index.php。

To modify the head section you need to access to the admin dashboard. Inside Extensions/Themes, then into themes select your default theme. Go into the editor select the file /html/com_content/default.php and you could modified the file as you want.

At the same place you could find the file index.php that has the header section.

离旧人 2024-10-17 18:11:51

使用Joomla 4,但我认为在Joomla 3中是一样的,您可以读取标题,添加到它们,然后将它们写回。您可以在模板的index.php 靠近顶部的位置执行此操作。例如,代码看起来像:

$doc = JFactory::getDocument();
# get the headers
$head_data = $doc->getHeadData();
# twitter
$head_data["metaTags"]["name"]["twitter:card"] = "summary_large_image";
$head_data["metaTags"]["name"]["twitter:title"] = $head_data["title"];
$head_data["metaTags"]["name"]["twitter:description"] = $head_data["description"];
$head_data["metaTags"]["name"]["twitter:site"] = "@StreetArtAberde";
$head_data["metaTags"]["name"]["twitter:creator"] = "@AndyGasman";
$head_data["metaTags"]["name"]["twitter:image"] = Uri::root() . "images/my_image_for_twitter_card.jpg";
# open graph / facebook
$head_data["metaTags"]["property"]["og:title"] = $head_data["title"];
$head_data["metaTags"]["property"]["og:description"] = $head_data["description"];
$head_data["metaTags"]["property"]["og:url"] = $url;
$head_data["metaTags"]["property"]["og:image"] = Uri::root() . "images/metadata_images/street_art_aberdeen_map.jpg";
$head_data["metaTags"]["property"]["og:type"] = "website";
# set it back
$doc->setHeadData($head_data);

这会将社交元数据添加到标签,例如......

<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Map - Street Art Aberdeen">
<meta name="twitter:description" content="Street Art Aberdeen is a collaborative visual guide to street art in the city of Aberdeen, Scotland">
<meta name="twitter:site" content="@StreetArtAberde">
<meta name="twitter:creator" content="@AndyGasman">
<meta name="twitter:image" content="https://streetartaberdeen.org/images/metadata_images/street_art_aberdeen_map.jpg">
<meta property="og:title" content="Map - Street Art Aberdeen">
<meta property="og:description" content="Street Art Aberdeen is a collaborative visual guide to street art in the city of Aberdeen, Scotland">
<meta property="og:url" content="https://streetartaberdeen.org/">
<meta property="og:image" content="https://streetartaberdeen.org/images/metadata_images/street_art_aberdeen_map.jpg">
<meta property="og:type" content="website">

Using Joomla 4, but I think it's the same in Joomla 3, you can read the headers, add to them, then write them back. You could do this in your template's index.php quite close to the top. The code would, for example, look like:

$doc = JFactory::getDocument();
# get the headers
$head_data = $doc->getHeadData();
# twitter
$head_data["metaTags"]["name"]["twitter:card"] = "summary_large_image";
$head_data["metaTags"]["name"]["twitter:title"] = $head_data["title"];
$head_data["metaTags"]["name"]["twitter:description"] = $head_data["description"];
$head_data["metaTags"]["name"]["twitter:site"] = "@StreetArtAberde";
$head_data["metaTags"]["name"]["twitter:creator"] = "@AndyGasman";
$head_data["metaTags"]["name"]["twitter:image"] = Uri::root() . "images/my_image_for_twitter_card.jpg";
# open graph / facebook
$head_data["metaTags"]["property"]["og:title"] = $head_data["title"];
$head_data["metaTags"]["property"]["og:description"] = $head_data["description"];
$head_data["metaTags"]["property"]["og:url"] = $url;
$head_data["metaTags"]["property"]["og:image"] = Uri::root() . "images/metadata_images/street_art_aberdeen_map.jpg";
$head_data["metaTags"]["property"]["og:type"] = "website";
# set it back
$doc->setHeadData($head_data);

This would add social metadata to tags, like...

<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Map - Street Art Aberdeen">
<meta name="twitter:description" content="Street Art Aberdeen is a collaborative visual guide to street art in the city of Aberdeen, Scotland">
<meta name="twitter:site" content="@StreetArtAberde">
<meta name="twitter:creator" content="@AndyGasman">
<meta name="twitter:image" content="https://streetartaberdeen.org/images/metadata_images/street_art_aberdeen_map.jpg">
<meta property="og:title" content="Map - Street Art Aberdeen">
<meta property="og:description" content="Street Art Aberdeen is a collaborative visual guide to street art in the city of Aberdeen, Scotland">
<meta property="og:url" content="https://streetartaberdeen.org/">
<meta property="og:image" content="https://streetartaberdeen.org/images/metadata_images/street_art_aberdeen_map.jpg">
<meta property="og:type" content="website">
╭ゆ眷念 2024-10-17 18:11:51

Joomla(甚至版本 3.6.x)不提供任何通过管理 UI 执行此操作的机制。有一些不同的较低级别选项(请参阅 https://docs.joomla.org/J3 .x:Adding_JavaScript_and_CSS_to_the_page),但非开发人员可能会发现很难使用。

有一些 Joomla 模板允许您指定要放置在标头末尾和/或正文部分末尾的全局自定义代码(例如 Google Analytics)。我正在使用这个: https://www.joomshaper.com/joomla-templates/helix3

Joomla (even version 3.6.x) doesn't provide any mechanism to do this via the admin UI. There are a few different lower-level options (see https://docs.joomla.org/J3.x:Adding_JavaScript_and_CSS_to_the_page) but non-developers may find it hard to use.

There are some Joomla templates that allow you to specify global custom code to be placed at the end of header and/or end of body sections (for example for Google Analytics). I'm using this one: https://www.joomshaper.com/joomla-templates/helix3

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文