Skip to content

Favicon guide

How to add a favicon in Astro

New Astro projects ship with the Astro logo as favicon.svg. Replace the files in public/ and update your layout once, and every page gets the new icon.

Updated November 11, 2026

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.webmanifest

2. 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.

Make your favicon in a minute

FavMint is a free favicon generator that runs in your browser. Design an icon from letters, symbols, or 2,100+ icons, check it at real sizes, and download the full package: favicon.ico, SVG, PNGs, the Apple touch icon, Android icons, and site.webmanifest. No signup, nothing uploaded.