Change favicon Vuejs?
Asked Answered
V

5

9

How to change favicon on Vuejs CLI ?

<link rel="shortcut icon" type="image/png" href="/src/assets/img/logo.png"/>
Vigilant answered 8/11, 2018 at 20:59 Comment(3)
the favicon.ico is stored in the public folderArvonio
What about #40191024Ship
Possible duplicate of How to set favicon.ico properly on vue.js webpack project?Fecula
Y
14

Vue CLI (3.0.5) generates projects with the <root>/public directory containing the favicon.ico and index.html (which references the favicon.ico).

It seems you have your icon in <root>/src/assets. I recommend moving it to <root>/public, replacing favicon.ico with jinane-logo-JC.png, and updating index.html accordingly:

<!-- <link rel="icon" href="<%= BASE_URL %>favicon.ico"> --> <!-- REPLACE THIS -->
<link rel="icon" href="<%= BASE_URL %>jinane-logo-JC.png">
Yestreen answered 9/11, 2018 at 7:27 Comment(0)
R
4
(function() {
    var link = document.querySelector("link[rel*='icon']") || document.createElement('link');
    link.type = 'image/x-icon';
    link.rel = 'shortcut icon';
    link.href = 'http://www.stackoverflow.com/favicon.ico';
    document.getElementsByTagName('head')[0].appendChild(link);
})();
Rella answered 11/12, 2018 at 6:11 Comment(0)
M
2

if you are using vue cli2, put your fovicon in static files and change <link rel="shortcut icon" type="image/png" href="static/jinane-logo-JC.png"/> or you are using vue cli3, put your favicon image in public file and change it in index.html in public <link rel="icon" href="<%= BASE_URL %>jinane-logo-JC.png">

Monofilament answered 17/1, 2019 at 23:11 Comment(0)
W
0

Follow these Steps : -

  1. Copy your desired favicon in public folder in Vue project.
  2. Go to your project and look for index.html
  3. Find link tag for icon & replace name of "youlogohere" to your logo name

    < link rel="icon" href="<%= BASE_URL %>yourlogohere.png">

  4. Run Project and Icon changed.

Waitress answered 26/11, 2019 at 7:14 Comment(0)
D
0

You shold use vue-head package

Add this code in your App.vue file:

  export default {
    head: {
       link: [
             {
                 rel: "icon",
                 href: require("./assets/logo.png")
             },
          ]
       }
   }

goodluck!

Distress answered 26/1, 2021 at 1:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.