minimin_bamm
minimin_bamm

Reputation: 109

Is there a way to add a favicon in react-static?

I saw this

enter link description here

and I add favicon like this

import path from 'path';
import React from 'react';

export default {
  Document: ({
    Html,
    Head,
    Body,
    children,
    state: { siteData, renderMeta },
  }) => (
    <Html lang="en-US">
      <Head>
        <meta charSet="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <link rel="shortcut icon" href="favicon.ico" />
        <link rel="icon" href="favicon.ico" />
      </Head>
      <Body>{children}</Body>
    </Html>
  ),
  plugins: [
    ...
  ],
}

but is not working

Perhaps the image is not working properly in A. I tried to put the image inside the <body> but it didn't come out properly.

Upvotes: 1

Views: 717

Answers (1)

minimin_bamm
minimin_bamm

Reputation: 109

It's solved by building it.

I build it on the server using react-static-plugin-favicons plug-in.

 [
      'react-static-plugin-favicons',
      { 

        outputDir: path.join(__dirname, 'dist'),
        inputFile: path.resolve(__dirname, 'favicon.png') },
    ],

using netlify

Upvotes: 1

Related Questions