简体   繁体   English

我如何更改 Typo3 中的 Favicon

[英]How do i change Favicon in Typo3

I want to change favicon from e new Typo3 site (Version 9.5.9).我想从新的 Typo3 站点(版本 9.5.9)更改网站图标。 At currently it shows typo3 own icon.目前它显示 typo3 自己的图标。

I tried as described here https://wiki.typo3.org/Add_your_own_favicon but it stills shows typo3 icon.我按照这里的描述尝试了https://wiki.typo3.org/Add_your_own_favicon但它仍然显示 typo3 图标。

I have cleared browser cache and server cache already.我已经清除了浏览器缓存和服务器缓存。

Browsers are sometimes very stubborn in caching favicons.浏览器有时在缓存网站图标方面非常顽固。 I know two solutions so far:到目前为止,我知道两种解决方案:

  • Clicking multiple times CTRL+F5 until the new icon is shown (but visitors will probably still see the old icon)多次单击 CTRL+F5 直到显示新图标(但访问者可能仍会看到旧图标)
  • You could try to use a dummy version parameter in the file reference like this page.shortcutIcon = fileadmin/files/favicon.ico?v=xQO7OjawKd which also should solve the issue for normal visitors.您可以尝试在文件参考中使用虚拟版本参数,如page.shortcutIcon = fileadmin/files/favicon.ico?v=xQO7OjawKd这也应该可以解决普通访问者的问题。 I'm currently not sure if this works with page.shortcutIcon =...我目前不确定这是否适用于page.shortcutIcon =...

But remeber this code replaces the old school icon only.但请记住,此代码仅替换旧学校图标。 Nowadays you probably want to show alternative icons for all the given plattforms and devices too, see https://realfavicongenerator.net/ .现在您可能还想为所有给定的平台和设备显示替代图标,请参阅https://realfavicongenerator.net/

To do so you need some more code in your TS setup.为此,您需要在 TS 设置中添加更多代码。 The simplest would be to copy the html code from your favicon generator and place it in your TS like this:最简单的方法是从您的网站图标生成器中复制 html 代码并将其放入您的 TS 中,如下所示:

page.headerData.1568907945 = TEXT
page.headerData.1568907945.value (
  <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png?v=xQO7OjawKd">
  <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png?v=xQO7OjawKd">
  <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png?v=xQO7OjawKd">
  <link rel="manifest" href="/site.webmanifest?v=xQO7OjawKd">
  <link rel="mask-icon" href="/safari-pinned-tab.svg?v=xQO7OjawKd" color="#5bbad5">
  <meta name="msapplication-TileColor" content="#da532c">
  <meta name="theme-color" content="#ffffff">
)

The part <link rel="shortcut icon" href="/favicon.ico?v=xQO7OjawKd"> you should remove because this one is generated by page.shortcutIcon . <link rel="shortcut icon" href="/favicon.ico?v=xQO7OjawKd">您应该删除部分,因为这是由page.shortcutIcon生成的。 If the version parameter does not work you can try the leave it here and delete the old one with page.shortcutIcon > .如果版本参数不起作用,您可以尝试将其保留在这里并使用page.shortcutIcon >删除旧的。

I hope this helps and the code works, it's just written out of the head;) If not just leave a comment and I'll fix it...我希望这会有所帮助并且代码有效,它只是写在脑海中;)如果不只是发表评论,我会修复它......

And by the way you referred a very old wiki entry.顺便说一句,您提到了一个非常古老的 wiki 条目。 You should not store such files in fileadmin, therefore create your own sitepackage see https://www.sitepackagebuilder.com/ and place the icons into Ressources/Public/Icons or to the web root and the TS setup into Configuration/TypoScript/setup.typoscript.您不应将此类文件存储在 fileadmin 中,因此请创建自己的站点包,请参阅https://www.sitepackagebuilder.com/并将图标放入 Ressources/Public/Icons 或 web 根目录中,并将 TS 设置放入 Configuration/TypoScript/setup .排版。

A more dynamic implementation you can find at https://github.com/gstypo3/gsfavicon/blob/master/Configuration/TypoScript/setup.typoscript .您可以在https://github.com/gstypo3/gsfavicon/blob/master/Configuration/TypoScript/setup.typoscript找到更动态的实现。

This whole procedure works for the frontend only but I guess backend was not the question.整个过程仅适用于前端,但我想后端不是问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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