Can't setup favicon Angular 6 app












0














I am using Angular 6 and can't setup favicon for my app. It is absent at all. Here is my angular.json file:



{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"frontend": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "../wwwroot/dist",
"deployUrl": "/dist/",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
"polyfills": "src/polyfills.ts",
"assets": [
"src/assets",
"src/favicon.ico"
],
"styles": [
"src/styles.scss"
],
"scripts":
},
"configurations": {
"production": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "frontend:build",
"proxyConfig": "proxy.conf.json"
},
"configurations": {
"production": {
"browserTarget": "frontend:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "frontend:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"karmaConfig": "./karma.conf.js",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"scripts": ,
"styles": [
"src/styles.scss"
],
"assets": [
"src/assets",
"src/favicon.ico"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"frontend-e2e": {
"root": "",
"sourceRoot": "",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "./protractor.conf.js",
"devServerTarget": "frontend:serve"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"e2e/tsconfig.e2e.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "frontend",
"schematics": {
"@schematics/angular:component": {
"prefix": "app",
"styleext": "scss"
},
"@schematics/angular:directive": {
"prefix": "app"
}
}
}


In index.html i have <link rel="icon" type="image/x-icon" href="favicon.ico">.



favicon.ico located in src/favicon.ico.



I have already tried to clear cash and restart app multiple times as people advised in similar questions, but it didn't help.
Also tried to add dummy param to favicon in index.html like href="favicon.ico?any=param"



What should i do for make it works? Thank you.










share|improve this question






















  • What is the exact error here? Does it find an image or do you get a 404 for the favicon.ico? You can try to do a 'ng build' and check the 'dist' folder. When the correct favicon.ico was copied in the folder, it was a probably a caching issue.
    – Daniel Beckmann
    Jun 13 at 12:52










  • I didn't get any error. Favicon in the vrowser is just empty
    – Denis Yalomist
    Jun 13 at 13:23










  • in your angular.json, try using favicon.ico instead of src/favicon.ico. That's how my app is set up and the favicon is in the src/ directory.
    – rhavelka
    Jun 13 at 13:56












  • @rhavelka if i do so - i will get an error The favicon.ico asset path must start with the project source root.
    – Denis Yalomist
    Jun 13 at 14:05










  • Ok, I have my "root": "src" which explains that error and why I don't have src prefixing any of my files. But it doesn't explain why your favicon isn't working... I assume that you have a favicon.ico, and it isn't anything like favicon.png. Does anything show up on your tab like the default favicon?
    – rhavelka
    Jun 13 at 14:15


















0














I am using Angular 6 and can't setup favicon for my app. It is absent at all. Here is my angular.json file:



{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"frontend": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "../wwwroot/dist",
"deployUrl": "/dist/",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
"polyfills": "src/polyfills.ts",
"assets": [
"src/assets",
"src/favicon.ico"
],
"styles": [
"src/styles.scss"
],
"scripts":
},
"configurations": {
"production": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "frontend:build",
"proxyConfig": "proxy.conf.json"
},
"configurations": {
"production": {
"browserTarget": "frontend:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "frontend:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"karmaConfig": "./karma.conf.js",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"scripts": ,
"styles": [
"src/styles.scss"
],
"assets": [
"src/assets",
"src/favicon.ico"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"frontend-e2e": {
"root": "",
"sourceRoot": "",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "./protractor.conf.js",
"devServerTarget": "frontend:serve"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"e2e/tsconfig.e2e.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "frontend",
"schematics": {
"@schematics/angular:component": {
"prefix": "app",
"styleext": "scss"
},
"@schematics/angular:directive": {
"prefix": "app"
}
}
}


In index.html i have <link rel="icon" type="image/x-icon" href="favicon.ico">.



favicon.ico located in src/favicon.ico.



I have already tried to clear cash and restart app multiple times as people advised in similar questions, but it didn't help.
Also tried to add dummy param to favicon in index.html like href="favicon.ico?any=param"



What should i do for make it works? Thank you.










share|improve this question






















  • What is the exact error here? Does it find an image or do you get a 404 for the favicon.ico? You can try to do a 'ng build' and check the 'dist' folder. When the correct favicon.ico was copied in the folder, it was a probably a caching issue.
    – Daniel Beckmann
    Jun 13 at 12:52










  • I didn't get any error. Favicon in the vrowser is just empty
    – Denis Yalomist
    Jun 13 at 13:23










  • in your angular.json, try using favicon.ico instead of src/favicon.ico. That's how my app is set up and the favicon is in the src/ directory.
    – rhavelka
    Jun 13 at 13:56












  • @rhavelka if i do so - i will get an error The favicon.ico asset path must start with the project source root.
    – Denis Yalomist
    Jun 13 at 14:05










  • Ok, I have my "root": "src" which explains that error and why I don't have src prefixing any of my files. But it doesn't explain why your favicon isn't working... I assume that you have a favicon.ico, and it isn't anything like favicon.png. Does anything show up on your tab like the default favicon?
    – rhavelka
    Jun 13 at 14:15
















0












0








0







I am using Angular 6 and can't setup favicon for my app. It is absent at all. Here is my angular.json file:



{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"frontend": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "../wwwroot/dist",
"deployUrl": "/dist/",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
"polyfills": "src/polyfills.ts",
"assets": [
"src/assets",
"src/favicon.ico"
],
"styles": [
"src/styles.scss"
],
"scripts":
},
"configurations": {
"production": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "frontend:build",
"proxyConfig": "proxy.conf.json"
},
"configurations": {
"production": {
"browserTarget": "frontend:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "frontend:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"karmaConfig": "./karma.conf.js",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"scripts": ,
"styles": [
"src/styles.scss"
],
"assets": [
"src/assets",
"src/favicon.ico"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"frontend-e2e": {
"root": "",
"sourceRoot": "",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "./protractor.conf.js",
"devServerTarget": "frontend:serve"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"e2e/tsconfig.e2e.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "frontend",
"schematics": {
"@schematics/angular:component": {
"prefix": "app",
"styleext": "scss"
},
"@schematics/angular:directive": {
"prefix": "app"
}
}
}


In index.html i have <link rel="icon" type="image/x-icon" href="favicon.ico">.



favicon.ico located in src/favicon.ico.



I have already tried to clear cash and restart app multiple times as people advised in similar questions, but it didn't help.
Also tried to add dummy param to favicon in index.html like href="favicon.ico?any=param"



What should i do for make it works? Thank you.










share|improve this question













I am using Angular 6 and can't setup favicon for my app. It is absent at all. Here is my angular.json file:



{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"frontend": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "../wwwroot/dist",
"deployUrl": "/dist/",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
"polyfills": "src/polyfills.ts",
"assets": [
"src/assets",
"src/favicon.ico"
],
"styles": [
"src/styles.scss"
],
"scripts":
},
"configurations": {
"production": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "frontend:build",
"proxyConfig": "proxy.conf.json"
},
"configurations": {
"production": {
"browserTarget": "frontend:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "frontend:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"karmaConfig": "./karma.conf.js",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"scripts": ,
"styles": [
"src/styles.scss"
],
"assets": [
"src/assets",
"src/favicon.ico"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"frontend-e2e": {
"root": "",
"sourceRoot": "",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "./protractor.conf.js",
"devServerTarget": "frontend:serve"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"e2e/tsconfig.e2e.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "frontend",
"schematics": {
"@schematics/angular:component": {
"prefix": "app",
"styleext": "scss"
},
"@schematics/angular:directive": {
"prefix": "app"
}
}
}


In index.html i have <link rel="icon" type="image/x-icon" href="favicon.ico">.



favicon.ico located in src/favicon.ico.



I have already tried to clear cash and restart app multiple times as people advised in similar questions, but it didn't help.
Also tried to add dummy param to favicon in index.html like href="favicon.ico?any=param"



What should i do for make it works? Thank you.







javascript angular favicon angular6






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jun 13 at 12:31









Denis Yalomist

307215




307215












  • What is the exact error here? Does it find an image or do you get a 404 for the favicon.ico? You can try to do a 'ng build' and check the 'dist' folder. When the correct favicon.ico was copied in the folder, it was a probably a caching issue.
    – Daniel Beckmann
    Jun 13 at 12:52










  • I didn't get any error. Favicon in the vrowser is just empty
    – Denis Yalomist
    Jun 13 at 13:23










  • in your angular.json, try using favicon.ico instead of src/favicon.ico. That's how my app is set up and the favicon is in the src/ directory.
    – rhavelka
    Jun 13 at 13:56












  • @rhavelka if i do so - i will get an error The favicon.ico asset path must start with the project source root.
    – Denis Yalomist
    Jun 13 at 14:05










  • Ok, I have my "root": "src" which explains that error and why I don't have src prefixing any of my files. But it doesn't explain why your favicon isn't working... I assume that you have a favicon.ico, and it isn't anything like favicon.png. Does anything show up on your tab like the default favicon?
    – rhavelka
    Jun 13 at 14:15




















  • What is the exact error here? Does it find an image or do you get a 404 for the favicon.ico? You can try to do a 'ng build' and check the 'dist' folder. When the correct favicon.ico was copied in the folder, it was a probably a caching issue.
    – Daniel Beckmann
    Jun 13 at 12:52










  • I didn't get any error. Favicon in the vrowser is just empty
    – Denis Yalomist
    Jun 13 at 13:23










  • in your angular.json, try using favicon.ico instead of src/favicon.ico. That's how my app is set up and the favicon is in the src/ directory.
    – rhavelka
    Jun 13 at 13:56












  • @rhavelka if i do so - i will get an error The favicon.ico asset path must start with the project source root.
    – Denis Yalomist
    Jun 13 at 14:05










  • Ok, I have my "root": "src" which explains that error and why I don't have src prefixing any of my files. But it doesn't explain why your favicon isn't working... I assume that you have a favicon.ico, and it isn't anything like favicon.png. Does anything show up on your tab like the default favicon?
    – rhavelka
    Jun 13 at 14:15


















What is the exact error here? Does it find an image or do you get a 404 for the favicon.ico? You can try to do a 'ng build' and check the 'dist' folder. When the correct favicon.ico was copied in the folder, it was a probably a caching issue.
– Daniel Beckmann
Jun 13 at 12:52




What is the exact error here? Does it find an image or do you get a 404 for the favicon.ico? You can try to do a 'ng build' and check the 'dist' folder. When the correct favicon.ico was copied in the folder, it was a probably a caching issue.
– Daniel Beckmann
Jun 13 at 12:52












I didn't get any error. Favicon in the vrowser is just empty
– Denis Yalomist
Jun 13 at 13:23




I didn't get any error. Favicon in the vrowser is just empty
– Denis Yalomist
Jun 13 at 13:23












in your angular.json, try using favicon.ico instead of src/favicon.ico. That's how my app is set up and the favicon is in the src/ directory.
– rhavelka
Jun 13 at 13:56






in your angular.json, try using favicon.ico instead of src/favicon.ico. That's how my app is set up and the favicon is in the src/ directory.
– rhavelka
Jun 13 at 13:56














@rhavelka if i do so - i will get an error The favicon.ico asset path must start with the project source root.
– Denis Yalomist
Jun 13 at 14:05




@rhavelka if i do so - i will get an error The favicon.ico asset path must start with the project source root.
– Denis Yalomist
Jun 13 at 14:05












Ok, I have my "root": "src" which explains that error and why I don't have src prefixing any of my files. But it doesn't explain why your favicon isn't working... I assume that you have a favicon.ico, and it isn't anything like favicon.png. Does anything show up on your tab like the default favicon?
– rhavelka
Jun 13 at 14:15






Ok, I have my "root": "src" which explains that error and why I don't have src prefixing any of my files. But it doesn't explain why your favicon isn't working... I assume that you have a favicon.ico, and it isn't anything like favicon.png. Does anything show up on your tab like the default favicon?
– rhavelka
Jun 13 at 14:15














2 Answers
2






active

oldest

votes


















0














The public folder for images and static stuff is /assets. Put the icon-image in there.



<link rel="icon" type="image/x-icon" href="assets/images/icon.png">





share|improve this answer





























    0














    Put your favicon.png in your asset folder and change the path in index.html like so:



    <link rel="icon" type="image/x-icon" href="./assets/favicon.png">





    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50837354%2fcant-setup-favicon-angular-6-app%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      The public folder for images and static stuff is /assets. Put the icon-image in there.



      <link rel="icon" type="image/x-icon" href="assets/images/icon.png">





      share|improve this answer


























        0














        The public folder for images and static stuff is /assets. Put the icon-image in there.



        <link rel="icon" type="image/x-icon" href="assets/images/icon.png">





        share|improve this answer
























          0












          0








          0






          The public folder for images and static stuff is /assets. Put the icon-image in there.



          <link rel="icon" type="image/x-icon" href="assets/images/icon.png">





          share|improve this answer












          The public folder for images and static stuff is /assets. Put the icon-image in there.



          <link rel="icon" type="image/x-icon" href="assets/images/icon.png">






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 12 at 2:48









          Sergi

          656




          656

























              0














              Put your favicon.png in your asset folder and change the path in index.html like so:



              <link rel="icon" type="image/x-icon" href="./assets/favicon.png">





              share|improve this answer




























                0














                Put your favicon.png in your asset folder and change the path in index.html like so:



                <link rel="icon" type="image/x-icon" href="./assets/favicon.png">





                share|improve this answer


























                  0












                  0








                  0






                  Put your favicon.png in your asset folder and change the path in index.html like so:



                  <link rel="icon" type="image/x-icon" href="./assets/favicon.png">





                  share|improve this answer














                  Put your favicon.png in your asset folder and change the path in index.html like so:



                  <link rel="icon" type="image/x-icon" href="./assets/favicon.png">






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Nov 12 at 3:17









                  Smokey Dawson

                  1,795939




                  1,795939










                  answered Nov 5 at 19:52









                  user1795667

                  465




                  465






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50837354%2fcant-setup-favicon-angular-6-app%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Florida Star v. B. J. F.

                      Error while running script in elastic search , gateway timeout

                      Adding quotations to stringified JSON object values