Marketplace Image ResizerMARKETPLACE IMAGE RESIZER
Implementation

Favicon Implementation Guide

Complete step-by-step guide to implementing favicons. HTML code, file placement, manifest.json setup, CDN configuration, and platform-specific instructions.

Generate Implementation Code →

Quick Start: 3-Step Implementation

The fastest way to add favicons to your website. This basic setup works for 95% of use cases and takes less than 5 minutes.

1

Create Icons

Generate favicon-32x32.png, favicon-16x16.png, and apple-touch-icon.png from your logo.

2

Upload Files

Place the PNG files in your website's root directory or /public folder.

3

Add HTML

Copy the link tags into your HTML <head> section. Done!

Basic Implementation (3 Files)

HTML Code

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Your Website</title>
  
  <!-- Favicon -->
  <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
  <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
</head>
<body>
  <!-- Your content -->
</body>
</html>

Complete Implementation (All Platforms)

For maximum compatibility including PWAs, Android home screens, Windows tiles, and legacy browsers, use this comprehensive setup:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Your Website</title>
  
  <!-- Primary favicon (modern browsers) -->
  <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
  
  <!-- SVG favicon for modern browsers with dark mode support -->
  <link rel="icon" type="image/svg+xml" href="/favicon.svg">
  
  <!-- ICO fallback for IE11 -->
  <link rel="shortcut icon" href="/favicon.ico">
  
  <!-- Apple Touch Icons -->
  <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
  <link rel="apple-touch-icon" sizes="152x152" href="/apple-touch-icon-152x152.png">
  <link rel="apple-touch-icon" sizes="120x120" href="/apple-touch-icon-120x120.png">
  
  <!-- Android/Chrome -->
  <link rel="manifest" href="/manifest.json">
  <meta name="theme-color" content="#ffffff">
  
  <!-- Windows Tiles -->
  <meta name="msapplication-TileColor" content="#ffffff">
  <meta name="msapplication-config" content="/browserconfig.xml">
  
  <!-- Safari Pinned Tab -->
  <link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
</head>
<body>
  <!-- Your content -->
</body>
</html>

File Placement by Platform

Static HTML Sites

Place all favicon files in your root directory (same level as index.html).

your-website/
ā”œā”€ā”€ index.html
ā”œā”€ā”€ favicon.ico
ā”œā”€ā”€ favicon.svg
ā”œā”€ā”€ favicon-16x16.png
ā”œā”€ā”€ favicon-32x32.png
ā”œā”€ā”€ apple-touch-icon.png
ā”œā”€ā”€ android-chrome-192x192.png
ā”œā”€ā”€ android-chrome-512x512.png
└── manifest.json

CDN and Subdomain Setup

If you host static assets on a CDN or subdomain, you'll need to adjust paths and handle CORS for manifest.json.

CDN Implementation

<!-- Favicons hosted on CDN -->
<link rel="icon" type="image/png" sizes="32x32" 
      href="https://cdn.example.com/favicons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" 
      href="https://cdn.example.com/favicons/favicon-16x16.png">
<link rel="apple-touch-icon" sizes="180x180" 
      href="https://cdn.example.com/favicons/apple-touch-icon.png">

<!-- Manifest MUST be same-origin or use CORS -->
<link rel="manifest" href="/manifest.json">

CORS Headers for CDN Manifest

If you must host manifest.json on a CDN, add these headers:

Access-Control-Allow-Origin: https://example.com
Access-Control-Allow-Methods: GET
Content-Type: application/json

Cache Busting and Updates

Browsers cache favicons aggressively. When updating your favicon, use these techniques to force refresh:

1. Query String Versioning

<link rel="icon" type="image/png" sizes="32x32" 
      href="/favicon-32x32.png?v=2">
<!-- Increment version number when updating favicon -->

āœ“ Simple and effective. Change `?v=2` to `?v=3` when updating.

2. Filename Hashing (Build Tools)

<link rel="icon" type="image/png" sizes="32x32" 
      href="/favicon-32x32.a3f8d9c2.png">
<!-- Build tool generates hash from file contents -->

āœ“ Automatic with Webpack/Vite. No manual version management.

3. Cache-Control Headers

# .htaccess (Apache)
<FilesMatch "\.(ico|png|svg)$">
  Header set Cache-Control "public, max-age=31536000, immutable"
</FilesMatch>

# nginx
location ~* \.(ico|png|svg)$ {
  expires 1y;
  add_header Cache-Control "public, immutable";
}

āœ“ Combine with query strings for optimal caching.

Testing Your Implementation

Quick Visual Test

  1. 1. Clear browser cache (Ctrl+Shift+Del)
  2. 2. Open your site in a new tab
  3. 3. Check browser tab shows your favicon
  4. 4. Bookmark the page, verify icon in bookmarks
  5. 5. Test on mobile: Add to home screen

Technical Validation

  • • Open DevTools → Network tab
  • • Reload page, check favicon requests (200 status)
  • • Validate manifest.json syntax: Manifest Validator
  • • Run Google Lighthouse audit
  • • Test in all major browsers

Common Implementation Issues

Issue: Favicon Not Showing

Browser shows default icon or no icon.

Solutions:

  • āœ“ Check file paths are correct (case-sensitive on Linux servers)
  • āœ“ Verify files uploaded to correct directory
  • āœ“ Clear browser cache (Ctrl+F5 or Cmd+Shift+R)
  • āœ“ Check DevTools Network tab for 404 errors
  • āœ“ Ensure HTML link tags are inside `<head>`

Issue: Wrong Icon Showing

Old favicon still appears after update.

Solutions:

  • āœ“ Add version query string: `favicon.png?v=2`
  • āœ“ Clear browser cache completely
  • āœ“ Test in incognito/private window
  • āœ“ Check CDN cache (purge if needed)
  • āœ“ Wait 24-48 hours for browser cache expiry

Issue: PWA Not Installable

Install prompt doesn't appear.

Solutions:

  • āœ“ Verify manifest.json is valid JSON (no syntax errors)
  • āœ“ Ensure 192x192 and 512x512 icons exist
  • āœ“ Check site is served over HTTPS
  • āœ“ Register a service worker
  • āœ“ Run Lighthouse PWA audit for detailed checklist

Advanced: Dynamic Favicons

You can dynamically update favicons using JavaScript for notifications or status indicators:

// Add notification count badge to favicon
function updateFavicon(notificationCount) {
  const canvas = document.createElement('canvas');
  canvas.width = 32;
  canvas.height = 32;
  const ctx = canvas.getContext('2d');
  
  // Draw base icon
  const img = new Image();
  img.onload = () => {
    ctx.drawImage(img, 0, 0, 32, 32);
    
    if (notificationCount > 0) {
      // Draw red badge
      ctx.fillStyle = '#FF0000';
      ctx.beginPath();
      ctx.arc(24, 8, 8, 0, 2 * Math.PI);
      ctx.fill();
      
      // Draw count
      ctx.fillStyle = '#FFFFFF';
      ctx.font = 'bold 12px Arial';
      ctx.textAlign = 'center';
      ctx.fillText(notificationCount, 24, 12);
    }
    
    // Update favicon
    const link = document.querySelector("link[rel*='icon']");
    link.href = canvas.toDataURL('image/png');
  };
  img.src = '/favicon-32x32.png';
}

// Usage
updateFavicon(5); // Shows "5" badge on favicon

Performance Optimization

Best Practices for Fast Loading

Optimize file sizes

Target: <3KB for 32x32 PNG, <10KB for 512x512. Use TinyPNG or similar.

Use HTTP/2 server push

Push favicon with initial HTML response for faster rendering.

Set long cache duration

Cache-Control: max-age=31536000 (1 year) with query string versioning.

Minimize file count

Only include sizes you actually need. 3-5 files is sufficient for most sites.

Auto-Generate Implementation Code

Our favicon generator creates all required files plus ready-to-use HTML code, manifest.json, and implementation instructions. Deploy in minutes.

Generate Code Now →

Related Implementation Resources

Testing Guide

How to test and verify your favicon implementation.

PWA Setup

Complete PWA manifest and service worker integration.

Common Mistakes

Avoid these frequent favicon implementation errors.