How to add a favicon to a Next.js static site?

后端 未结 6 1866
既然无缘
既然无缘 2021-02-03 20:52

I\'m trying to add a favicon to a Next.js static site without much luck.

I\'ve tried customising the document with components from \'next/document\' https:/

6条回答
  •  花落未央
    2021-02-03 21:16

    The accepted answer is nice, but might be worth pointing out that you don't have to modify _document.js for adding a favicon (nor for adding any tags to head).

    I found out for myself that placing favicon in _app.js makes more sense. This file is most likely to exist already for setting up a layout for the pages or something like this. And you can add Head tag literally anywhere (see the docs)

    So I ended up with _app.js

    class MyApp extends App {
      render() {
      const { Component, pageProps } = this.props;
      return (
        
          
            
          
          
        
      );
    }
    

提交回复
热议问题