1. Replace the files in public/
Astro copies public/ to the root of your built site untouched. Overwrite the starter favicon.svg (and favicon.ico, if your template has one) and add the rest:
public/
├── favicon.ico
├── favicon.svg
├── apple-touch-icon.png
├── android-chrome-192x192.png
├── android-chrome-512x512.png
└── site.webmanifest2. Add the tags to your layout
Open the layout every page uses (often src/layouts/Layout.astro or BaseHead.astro) and replace the existing icon line with:
<head>
<meta charset="utf-8" />
<link rel="icon" href="/favicon.ico" sizes="32x32" />
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
<link rel="manifest" href="/site.webmanifest" />
<title>{title}</title>
</head>Reference files in public/ by their root path (/favicon.svg), not with an import. Astro doesn't process them.
If your site uses a base path
With base: '/docs' in astro.config.mjs, root paths won't include the base for files in public/. Build the URL from import.meta.env.BASE_URL:
---
const base = import.meta.env.BASE_URL.replace(/\/$/, '');
---
<link rel="icon" href={`${base}/favicon.svg`} type="image/svg+xml" />Starlight docs sites
Starlight adds the favicon for you. Put the file in public/ and set it in the Starlight config: starlight({ favicon: '/favicon.svg' }). Add the Apple touch icon through the head option if you want one.