Communitygithub.com

favicon-setup

在任一網站或網頁應用程式中安裝一套完整、精簡的 favicon 素材 — 包含現代瀏覽器、iOS 與 Android 實際使用的五個檔案、只在根佈局中加入一次的 head 標記區塊,以及確認每個檔案都能正確解析的檢查。涵蓋依框架尋找 public 資料夾、從單一 SVG(或 RealFaviconGenerator 套件)產生素材、暗色模式 SVG 圖示、可遮罩的 manifest 圖示、快取更新與驗證。適用於新增、取代或稽核 favicon、應用程式圖示、apple-touch-icon 或網頁 Manifest。觸發關鍵字:favicon, favicon.ico, favicon.svg, apple-touch-icon, site.webmanifest, manifest.json, app icon, PWA icon, maskable icon, tab icon, RealFaviconGenerator。

favicon-setup 是什麼?

這項技能提供了一套完整且精簡的 favicon 設置方案,涵蓋了所有現代瀏覽器、iOS 主畫面以及 Android 安裝所需的五個核心檔案。它不僅能從單一 SVG 或 RealFaviconGenerator 套件自動產生這些素材,還詳細說明了如何針對不同前端框架(如 Vite、Next.js、SvelteKit 等)找到正確的 public 資料夾,並會自動加入正確的 HTML 標記或 Next.js 的 metadata 設定。此外,也包含了 SVG 深色模式支援、可遮罩的 PWA manifest 圖示、快取更新策略,以及一套完整的驗證指令,確保所有素材均正確部署。對於需要建立、替換或稽核網站 favicon 與 PWA 圖示的開發者來說,這項自動化技能能大幅減少手動處理的繁瑣與錯誤。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Adamparishspok/skills/tree/HEAD/skills/favicon-setup

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Favicon 設置

五個檔案與五個標籤即可涵蓋所有當前瀏覽器、iOS 主畫面以及 Android 安裝。更多尺寸(mstile-*、browserconfig.xml、57/72/114px Apple 圖示、mask-icon)屬於舊版:請直接跳過。

1. 檔案集合

檔案尺寸用途
favicon.svg向量現代瀏覽器分頁。可銳利縮放,並支援深色模式切換。
favicon-96x96.png96×96不支援 SVG favicon 的瀏覽器,以及 Google 搜尋結果。
favicon.ico單一檔案包含 16、32、48 像素舊版瀏覽器與直接請求 /favicon.ico 而不讀取 HTML 的工具。
apple-touch-icon.png180×180,不透明iOS 與 iPadOS 主畫面。
web-app-manifest-192x192.png、web-app-manifest-512x512.png192、512Android 主畫面、PWA 安裝、啟動畫面。
site.webmanifest—引導 Android 使用上述兩個 PNG 檔案。

2. 取得檔案

從 RealFaviconGenerator 套件。 它會提供一組下載網址。將每個檔案下載到 PUBLIC_FOLDER(請見步驟 3),並使用其確切檔名:

base=https://realfavicongenerator.net/files/<套件-id>
for f in favicon.svg favicon-96x96.png favicon.ico apple-touch-icon.png \
         web-app-manifest-192x192.png web-app-manifest-512x512.png site.webmanifest; do
  curl -fsSL "$base/$f" -o "PUBLIC_FOLDER/$f" || echo "失敗:$f"
done

如果下載失敗,請停止並回報。請勿提供不完整的素材。回報產生器錯誤請至: https://github.com/RealFaviconGenerator/realfavicongenerator/issues/new?template=ai_prompt_bug_report.yml。

從單一來源 SVG(需要 rsvg-convert 與 ImageMagick,或使用產生器):

cp logo.svg PUBLIC_FOLDER/favicon.svg
rsvg-convert -w 96  -h 96  logo.svg -o PUBLIC_FOLDER/favicon-96x96.png
rsvg-convert -w 192 -h 192 logo.svg -o PUBLIC_FOLDER/web-app-manifest-192x192.png
rsvg-convert -w 512 -h 512 logo.svg -o PUBLIC_FOLDER/web-app-manifest-512x512.png
# iOS 會將透明處填為黑色:將其壓平到品牌背景上,並留約 10% 邊距
rsvg-convert -w 144 -h 144 logo.svg | magick - -background '#ffffff' -gravity center -extent 180x180 -flatten PUBLIC_FOLDER/apple-touch-icon.png
magick -background none logo.svg -define icon:auto-resize=48,32,16 PUBLIC_FOLDER/favicon.ico

3. 找到 PUBLIC_FOLDER

這是網站根目錄對應的資料夾,因此 PUBLIC_FOLDER/favicon.ico 會載入為 /favicon.ico。

框架資料夾
Vite、Next.js、Create React App、Astro、Remix、Nuxt 3public/
SvelteKitstatic/
Angularpublic/(v17+)或 src/(需在 angular.json assets 中列出)
Hugo、Jekyll、Eleventystatic/、網站根目錄或 passthrough-copy 資料夾
純 HTML與 index.html 同層

Next.js App Router: 刪除預設的 app/favicon.ico。它會優先於 public/favicon.ico,且通常還是 Next.js 的標誌。

4. 僅加入一次標記

將下列內容放入負責渲染根 <html> 標籤的那一個檔案的 <head> 中。切勿每個頁面都加入。

<link rel="icon" type="image/png" href="/favicon-96x96.png" sizes="96x96" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
<link rel="manifest" href="/site.webmanifest" />
框架根檔案
Vite、CRA、純 HTMLindex.html
Next.js App Routerapp/layout.tsx,透過 metadata 匯出(如下所示),非直接寫入原始標籤
Next.js Pages Routerpages/_document.tsx 內的 <Head>
Astro基礎佈局,例如 src/layouts/Layout.astro
SvelteKitsrc/app.html
Remix / React Router 7app/root.tsx 中的 links 匯出
Nuxtnuxt.config.ts 中的 app.head.link

Next.js App Router 對應寫法:

export const metadata = {
  icons: {
    icon: [
      { url: "/favicon-96x96.png", sizes: "96x96", type: "image/png" },
      { url: "/favicon.svg", type: "image/svg+xml" },
    ],
    shortcut: "/favicon.ico",
    apple: { url: "/apple-touch-icon.png", sizes: "180x180" },
  },
  manifest: "/site.webmanifest",
};

在加入這些標記之前,請先搜尋專案中是否有既存的 rel="icon"、apple-touch-icon 與 manifest 標籤。請取代它們,不要加入第二組。如果網站是基於子路徑(base / basePath)提供服務,請為每個 href 加上前綴。

5. 最佳化

  • SVG 深色模式。 深色標誌在深色分頁列上會消失。在 SVG 中加入 media query:
    <style>path{fill:#111}@media (prefers-color-scheme:dark){path{fill:#fff}}</style>
    
  • 小尺寸。 在 16px 時,請移除精細細節與文字。使用圖標而非文字商標。
  • SVG 體積。 執行 npx svgo favicon.svg,將檔案大小維持在約 2 KB 以下。
  • Manifest。 填入 name、short_name、theme_color 與 background_color。讓 512 圖示可遮罩:將標誌維持在中央 80% 安全區域內、使用實色背景,並為其設定 "purpose": "maskable"。如果標誌不符合安全區域,請另行加入一個獨立的可遮罩圖示。
    {
      "name": "My App",
      "short_name": "App",
      "icons": [
        { "src": "/web-app-manifest-192x192.png", "sizes": "192x192", "type": "image/png", "purpose": "maskable" },
        { "src": "/web-app-manifest-512x512.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable" }
      ],
      "theme_color": "#ffffff",
      "background_color": "#ffffff",
      "display": "standalone"
    }
    
  • 快取。 瀏覽器會強烈快取 favicon。當你替換圖示時,請重新命名檔案,或為每個 href 以及 manifest 中的 src 值加上 ?v=2。

6. 驗證

  1. 每個檔案都應回傳 200 狀態碼與正確的內容類型。針對開發伺服器執行以下指令:
    for f in favicon.svg favicon-96x96.png favicon.ico apple-touch-icon.png \
             web-app-manifest-192x192.png web-app-manifest-512x512.png site.webmanifest; do
      printf '%s ' "$f"; curl -s -o /dev/null -w '%{http_code} %{content_type}\n' "http://localhost:PORT/$f"
    done
    
  2. 渲染出的 HTML 應僅包含一組標籤:curl -s http://localhost:PORT/ | grep -cE 'rel="(icon|shortcut icon|apple-touch-icon|manifest)"' 應輸出 5。
  3. 在 DevTools 中,開啟 Application → Manifest:應顯示無錯誤,且兩個圖示都能正常呈現。
  4. 在強制重新整理的分頁中,分別於淺色與深色模式下檢查圖示是否都可見。
  5. 在已部署的網址上,執行 RealFaviconGenerator 檢查工具(https://realfavicongenerator.net/favicon-checker)。

Individual skills in this repo

This repo contains 4 individual skills — each has its own dedicated page.

Adamparishspok/skills

Make a website, web app or online store ready for AI agents. Scan it with Cloudflare's Agent Readiness checks, decide which checks apply to this kind of site, ship the discovery files and headers in priority order, and add the AI-first basics the scanner does not score (server-rendered content, JSON-LD, llms.txt). Covers robots.txt AI rules, Content Signals, sitemap, Markdown for Agents (Accept text/markdown), Link headers, API catalog, OAuth discovery, auth.md, MCP server card, A2A agent card, agent skills index, WebMCP, and commerce protocols (ACP, UCP, AP2, MPP, x402). Use when making a site AI-ready, agent-ready or AI-first, or fixing an isitagentready.com or Cloudflare Agent Readiness report. Triggers on: AI ready, agent ready, AI-first, agent readiness, isitagentready, AI Crawl Control, Markdown for Agents, text/markdown, llms.txt, GPTBot, ClaudeBot, AI crawlers, Content-Signal, ai-train, api-catalog, .well-known, oauth-protected-resource, auth.md, MCP server card, agent card, agent skills, WebMCP, a...

Adamparishspok/skills

Give an interface one shared tempo and a small vocabulary of hover and state micro-interactions: duration tiers (tap/pop/hover/card/layout) for CSS and Motion, swap hand-offs, rows whose highlight grows in, trailing arrows, chevron nudges, card lifts without translate, scroll-edge fades, and icon/label swaps for copy and toggle buttons. Use when animations feel inconsistent, durations are scattered magic numbers, hovers only change colour, or a product feels flat or unfinished. Triggers on: animation duration, transition timing, hover state, micro-interaction, polish, copy button feedback, menu icon to close, back arrow, card hover, scroll fade, motion tokens, Framer Motion durations.

Adamparishspok/skills

Consolidate several apps or prototypes onto one shared component library without flattening their looks. Covers finding duplicated local components (buttons, selects, fields, modals, pagers, toasts), making shared components token-sized so each suite or app sets its own measurements, mapping variant names, deciding what stays app-specific, and the tailwind-merge traps that silently break custom tokens. Use when several apps each grew their own Btn/Select/Modal, when a design system's components "don't fit" a second product, or when retheming a family of apps. Triggers on: shared component library, design system consolidation, duplicate components, retheme, suite of apps, shadcn retokened, token-driven components, cn tailwind-merge custom tokens, variant mapping.

Adamparishspok/skills

Build or migrate a UI's neutral palette (grounds, surfaces, lines, ink/text) as an OKLCH formula driven by a few inputs instead of dozens of hand-picked hex values, with light and dark themes, per-step ladder overrides, a fit script that reproduces existing colours, and a browser contrast audit. Use when creating a theme, adding dark mode, retinting a product, auditing text contrast, or consolidating several apps' palettes. Triggers on: palette, neutrals, grey ramp, dark mode, theme tokens, oklch, retint, hue, contrast audit, design tokens, Tailwind @theme colours.

相關技能