1+ <!DOCTYPE html>
2+ < html lang ="zh ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6+ < title > 网站图标设置教程 - humensmoc</ title >
7+ < link rel ="stylesheet " href ="/css/main.css ">
8+ < link rel ="stylesheet " href ="/lib/font-awesome/css/all.min.css ">
9+ < link rel ="apple-touch-icon " sizes ="180x180 " href ="/images/favicon/apple-touch-icon.png ">
10+ < link rel ="icon " type ="image/png " sizes ="32x32 " href ="/images/favicon/favicon-32x32.png ">
11+ < link rel ="icon " type ="image/png " sizes ="16x16 " href ="/images/favicon/favicon-16x16.png ">
12+ < link rel ="manifest " href ="/images/favicon/site.webmanifest ">
13+ < link rel ="shortcut icon " href ="/images/favicon/favicon.ico ">
14+ < style >
15+ .tutorial-container {
16+ max-width : 800px ;
17+ margin : 0 auto;
18+ padding : 40px 20px ;
19+ line-height : 1.8 ;
20+ }
21+ .step-section {
22+ margin-bottom : 40px ;
23+ padding : 20px ;
24+ background : # f8f9fa ;
25+ border-radius : 10px ;
26+ box-shadow : 0 2px 5px rgba (0 , 0 , 0 , 0.05 );
27+ }
28+ .step-number {
29+ display : inline-block;
30+ width : 30px ;
31+ height : 30px ;
32+ background : # 222 ;
33+ color : white;
34+ text-align : center;
35+ line-height : 30px ;
36+ border-radius : 50% ;
37+ margin-right : 10px ;
38+ }
39+ .code-block {
40+ background : # f1f1f1 ;
41+ padding : 15px ;
42+ border-radius : 5px ;
43+ overflow-x : auto;
44+ font-family : monospace;
45+ margin : 15px 0 ;
46+ }
47+ .note-box {
48+ background : # fff3cd ;
49+ border-left : 4px solid # ffc107 ;
50+ padding : 15px ;
51+ margin : 20px 0 ;
52+ }
53+ </ style >
54+ </ head >
55+ < body >
56+ < div class ="nav-buttons " style ="padding: 20px; ">
57+ < a href ="/newblog.html " class ="nav-button ">
58+ < i class ="fa fa-arrow-left "> </ i > 返回博客
59+ </ a >
60+ < a href ="/ " class ="nav-button ">
61+ < i class ="fa fa-home "> </ i > 返回主页
62+ </ a >
63+ </ div >
64+
65+ < div class ="tutorial-container ">
66+ < h1 > 如何设置网站图标(Favicon)</ h1 >
67+
68+ < div class ="step-section ">
69+ < h2 > < span class ="step-number "> 1</ span > 准备图标文件</ h2 >
70+ < p > 首先需要准备以下尺寸的图标文件:</ p >
71+ < ul >
72+ < li > favicon.ico (16x16 或 32x32 像素)</ li >
73+ < li > favicon-16x16.png (16x16 像素)</ li >
74+ < li > favicon-32x32.png (32x32 像素)</ li >
75+ < li > apple-touch-icon.png (180x180 像素,用于 iOS 设备)</ li >
76+ < li > android-chrome-192x192.png (192x192 像素)</ li >
77+ < li > android-chrome-512x512.png (512x512 像素)</ li >
78+ </ ul >
79+
80+ < div class ="note-box ">
81+ < strong > 提示:</ strong > 可以使用 < a href ="https://realfavicongenerator.net/ " target ="_blank "> Real Favicon Generator</ a >
82+ 在线工具生成所有需要的图标文件。只需上传一个高质量的原始图像(建议至少 512x512 像素),工具会自动生成所有所需尺寸。
83+ </ div >
84+ </ div >
85+
86+ < div class ="step-section ">
87+ < h2 > < span class ="step-number "> 2</ span > 创建文件结构</ h2 >
88+ < p > 将生成的图标文件放在网站的 < code > /images/favicon/</ code > 目录下:</ p >
89+ < pre class ="code-block ">
90+ /images/favicon/
91+ ├── favicon.ico
92+ ├── favicon-16x16.png
93+ ├── favicon-32x32.png
94+ ├── apple-touch-icon.png
95+ ├── android-chrome-192x192.png
96+ ├── android-chrome-512x512.png
97+ └── site.webmanifest</ pre >
98+ </ div >
99+
100+ < div class ="step-section ">
101+ < h2 > < span class ="step-number "> 3</ span > 创建 Manifest 文件</ h2 >
102+ < p > 在 < code > /images/favicon/</ code > 目录下创建 < code > site.webmanifest</ code > 文件:</ p >
103+ < pre class ="code-block "> {
104+ "name": "网站名称",
105+ "short_name": "短名称",
106+ "icons": [
107+ {
108+ "src": "/images/favicon/android-chrome-192x192.png",
109+ "sizes": "192x192",
110+ "type": "image/png"
111+ },
112+ {
113+ "src": "/images/favicon/android-chrome-512x512.png",
114+ "sizes": "512x512",
115+ "type": "image/png"
116+ }
117+ ],
118+ "theme_color": "#ffffff",
119+ "background_color": "#ffffff",
120+ "display": "standalone"
121+ }</ pre >
122+ </ div >
123+
124+ < div class ="step-section ">
125+ < h2 > < span class ="step-number "> 4</ span > 添加 HTML 代码</ h2 >
126+ < p > 在所有页面的 < code > <head></ code > 标签中添加以下代码:</ p >
127+ < pre class ="code-block "> <link rel="apple-touch-icon" sizes="180x180" href="/images/favicon/apple-touch-icon.png">
128+ <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon/favicon-32x32.png">
129+ <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon/favicon-16x16.png">
130+ <link rel="manifest" href="/images/favicon/site.webmanifest">
131+ <link rel="shortcut icon" href="/images/favicon/favicon.ico"></ pre >
132+ </ div >
133+
134+ < div class ="step-section ">
135+ < h2 > 注意事项</ h2 >
136+ < ul >
137+ < li > 确保所有图标文件的路径正确</ li >
138+ < li > 图标文件应该清晰可辨,即使在小尺寸下也能识别</ li >
139+ < li > 建议使用 PNG 格式以保持最佳质量</ li >
140+ < li > 记得在所有页面都添加相关代码</ li >
141+ </ ul >
142+ </ div >
143+ </ div >
144+ </ body >
145+ </ html >
0 commit comments