myfavicon

How to Add a Favicon in a Vue or Nuxt Project

Vue and Nuxt render the page, but a browser finds the icon in the head. Vite and Vue CLI use a static index.html; Nuxt builds the head from a config file. This guide shows where the icon files go in each setup, the entries to add, subpath builds, and how to check the output.

Where the icon is declared

A browser looks for icon tags in the head of the served HTML, not inside a component. In Vite and Vue CLI that head is a plain HTML file; in Nuxt the framework generates it from a config object. Either way the favicon is a set of link entries, not template markup.

Static files are copied to the build output unchanged, so their URLs stay stable. The folder name differs between tools, and using the wrong one is a common reason for a missing icon.

SetupStatic folder and head source
Vue 3 with Vitepublic/ plus index.html at the project root
Vue CLIpublic/ plus public/index.html with a BASE_URL placeholder
Nuxt 3public/ plus app.head in nuxt.config.ts
Nuxt 2static/ plus head.link in nuxt.config.js

Vue 3 with Vite: public/ and index.html

Vite copies public/ to the root of dist/ without renaming files. Put the icons there and add the link tags inside the head of the root index.html. A leading slash resolves from the site root, matching where the files land.

Keep filenames identical in both places or the browser logs a 404. Build the set from one square image with the myfavicon generator, and see the size guide for each dimension.

<!-- index.html (Vite + Vue project root), inside <head> -->
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32.png">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="shortcut icon" href="/favicon.ico">
  • Create a public/ folder at the project root if missing.
  • Add the icon files with the exact filenames used in the tags.
  • Place the link block inside the head of index.html.
  • Build and confirm the files sit at the root of dist/.
  • Vue CLI: use the BASE_URL placeholder

    Vue CLI reads public/index.html as a webpack template and expects a BASE_URL placeholder before each asset path. The build replaces it with the public path, so icons still resolve when the app is served from a subdirectory.

    The starter ships a favicon.ico in public/; replacing it in place is simpler than adding more tags. See ICO vs PNG for the format trade-off.

    <!-- public/index.html (Vue CLI), inside <head> -->
    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
    <link rel="icon" type="image/svg+xml"
          href="<%= BASE_URL %>favicon.svg">
    <link rel="apple-touch-icon" sizes="180x180"
          href="<%= BASE_URL %>apple-touch-icon.png">

    Nuxt 3: app.head in nuxt.config.ts

    Nuxt 3 uses public/ for static assets and has no index.html to edit. Declare the icons in the app.head.link array of nuxt.config.ts, with root paths as href values.

    useHead() also works inside a component, but a site-wide icon belongs in the config. What a favicon is covers what each entry means.

    // nuxt.config.ts (Nuxt 3)
    export default defineNuxtConfig({
      app: {
        head: {
          link: [
            { rel: 'icon', type: 'image/svg+xml', href: '/favicon.svg' },
            { rel: 'icon', type: 'image/png', sizes: '32x32', href: '/favicon-32.png' },
            { rel: 'apple-touch-icon', sizes: '180x180', href: '/apple-touch-icon.png' }
          ]
        }
      }
    })

    Nuxt 2: static/ and head.link

    Nuxt 2 keeps static files in static/ and builds the head from head.link in nuxt.config.js. The href values look the same as in Nuxt 3, but the folder and config shape differ.

    When a project moves to Nuxt 3, the renamed static folder is a common cause of a broken icon. Check the folder first when the tags look correct but the icon is missing.

    // nuxt.config.js (Nuxt 2)
    export default {
      head: {
        link: [
          { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
          { rel: 'icon', type: 'image/svg+xml', href: '/favicon.svg' },
          { rel: 'apple-touch-icon', sizes: '180x180', href: '/apple-touch-icon.png' }
        ]
      }
    }
    DetailNuxt 2 vs Nuxt 3
    Static folderstatic/ in Nuxt 2, public/ in Nuxt 3
    Head confighead.link vs app.head.link
    Href valuesRoot paths such as /favicon.svg in both

    Serving the app under a subpath

    If the site is deployed below a path such as /app/, a leading slash points at the domain root and the icons go missing. Set base in Vite, publicPath in Vue CLI, app.baseURL in Nuxt 3, or router.base in Nuxt 2. Rebuild and read the generated HTML to confirm the prefix. Why a favicon is not showing lists the usual path and cache mistakes.

    Verify the result and fix a stale icon

    Trust the served HTML over the tab. Inspect the head in DevTools and request each icon URL directly. The favicon checker inspects a live URL the same way.

    For home screen and installable apps, see Apple touch icon, the web manifest and PWA icons. The general guide, the React guide, the Next.js guide, the WordPress guide and the Shopify guide follow the same checks on other stacks.

  • Build and open the generated HTML in dist/ or .output/.
  • Confirm every linked file exists at the declared path.
  • Open the app in a private window or hard refresh.
  • If the old icon persists, change the URL with a new filename or a version query string.
  • FAQ

    Do I need a plugin to add a favicon in Vue or Nuxt?

    No. Vite and Vue CLI read a static index.html, and Nuxt builds the head from a config object. A link entry and files in the right static folder are enough.

    Should the icons go in public/, static/, or src/assets?

    Use the static folder for your tool: public/ for Vite, Vue CLI and Nuxt 3, static/ for Nuxt 2. Files in src/assets are bundled and renamed with a hash.

    Why does the icon not change after I rebuild?

    Browsers cache favicons for a long time. Try a private window, then change the URL with a new filename or a version query string.

    Will a favicon affect my app's search rankings?

    You should not treat it as a ranking factor. Its job is recognition in tabs, bookmarks and home screen shortcuts.

    Make my favicon — free

    Related guides