Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i add favicon gatsby-config.js?

Tags:

gatsby

so i try to add favicon in my blog the code following bellow: in my gatsby-config.js

module.exports = {
  siteMetadata: {
    title: 'Chatbiz Blog',
  },
  plugins: [
    'gatsby-plugin-react-helmet',
    'gatsby-plugin-catch-links',
    {
      resolve: 'gatsby-source-filesystem',
      options: {
        path: `${__dirname}/src/pages`,
        name: 'pages',
        icon: `https://blablabla/favicon.ico`
      },
    },
    'gatsby-transformer-remark',
  ],
}

so the question is when i try to this code the favicon can't render in my blog how to solve the problem?

like image 486
setiawan wawan Avatar asked Aug 12 '19 09:08

setiawan wawan


People also ask

How do you set a favicon in Gatsby?

The favicon by default is the image static/favicon. ico . Just change that, and you're set. If you're using the gatsby-plugin-sharp plugin, the favicon by default is the image src/images/gatsby-icon.

How do I add a favicon to Webpack?

This is my server. js file: /* Global Requires */ const express = require('express'); const logger = require('morgan'); const bodyParser = require('body-parser'); const path = require('path'); const app = express(); const ReactDOM = require('react-dom') var favicon = require('serve-favicon'); if(process. env.


1 Answers

I believe, you are putting the icon params in wrong package options.

To solve this, first install the gatsby manifest plugin using the command below:

npm install --save gatsby-plugin-manifest

Then add this to your gatsby-config.js:

{
  resolve: `gatsby-plugin-manifest`,
  options: {
    name: `gatsby-starter-default`,
    short_name: `starter`,
    start_url: `/`,
    background_color: `#663399`,
    theme_color: `#663399`,
    display: `minimal-ui`,
    icon: `src/images/favicon.png`, // This path is relative to the root of the site.
  },

Remember to stop and start your development server in order to see your changes.

like image 177
Abhay Sharma Avatar answered Sep 26 '22 01:09

Abhay Sharma