How do i add favicon gatsby-config.js?

断了今生、忘了曾经 提交于 2019-12-11 17:05:36

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/57458658/how-do-i-add-favicon-gatsby-config-js

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!