问题描述
我正在尝试向我的网站添加网站图标。
此代码按预期工作
<head>
<link rel="icon" type="image/png" href="https://i.stack.imgur.com/YvjfT.png" sizes="16x16"/>
<title>home</title>
</head>
<body>
<h1>favicon png</h1>
</body>
我得到了这个
但是,当我更改 href 的值时
href="favicon.png"
我的网站不再加载。
我的 index.html 和 favicon.png 在同一个目录下。
我错过了什么?
解决方法
在选项卡中打开“index.html”文件的源代码,然后通过单击从代码中打开 favicon.png,然后在另一侧打开目录中另一个选项卡中的 favicon.png。现在比较两个URL,你会发现不同。