favicon 存在问题,只要路径与将其保存在与 html 相同的文件夹中不同,就无法显示该图标

发布于 2025-01-13 12:38:48 字数 228 浏览 6 评论 0 原文

>所以这不起作用

但这可以将 favicon 放在与html一. 我如何才能让它显示出来并将其保存在照片文件夹中?

<link rel="icon" type="image/x-icon" href="/photos/icon.ico" /> so this does not work

<link rel="icon" type="image/x-icon" href="icon.ico"> but this works having the favicon in the same folder as the html one.
How do I make it so that it will show up having it saved in the photos folder?

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

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

发布评论

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

评论(2

囚你心 2025-01-20 12:38:48

这是一个路径问题。你可以尝试以下两件事之一。

  1. 如果已经在实时服务器上,您可以将其定向到文件所在的位置,如下所示 href="https://www.example.com/photos/icon.ico" (如果您的照片文件夹,请记住正确的路径不在 public_html 中)

  2. 如果资源位于本地服务器上,您可以尝试使用“./”(与当前页面相同的文件夹)或“../”(当前页面的上一个文件夹)。

its a path problem. you can try one of two things.

  1. if on a live server already, you can direct it to where the file is located as this href="https://www.example.com/photos/icon.ico" (remember to path correctly if your photos folder isnt located in public_html)

  2. if the resource is located on a local server you can try using "./" (same folder as current page) or "../"(previous folder from current page).

爱情眠于流年 2025-01-20 12:38:48
<link rel="icon" type="image/x-icon" href="photos/icon.ico"/>

删除第一个“/”可能会解决此问题。如果没有,那是因为图像文件夹位置的原因。 images 文件夹位置应与 html 文件夹位于同一文件夹内。 HTML_folder/photos/icon.ico 从技术上讲是这样的,但它应该看起来像 photos/icon.ico

<link rel="icon" type="image/x-icon" href="photos/icon.ico"/>

Removing the first "/" may solve this problem. If it doesn't that is because of the images folder location. The images folder location should be inside the same folder as the html folder. HTML_folder/photos/icon.ico is what it technically is saying, but it should look like photos/icon.ico .
How files should be organized

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