Adding favicon to in React











up vote
3
down vote

favorite












I was trying to add a favicon in the <Helmet/> tag of a React App



my current <Helmet/> tag looks like this.



<Helmet
title="ABC"
meta={[
{ name: "ABC", content: "ABC" }
]}
links={
rel='icon',
type='image/png',
sizes='16x16',
href={require('favicon.ico')}
}

/>


But I'm getting an error about an unexpected token, any inputs on how to add a favicon? Thanks for the help in advance.










share|improve this question






















  • Just fyi: when you open braces in jsx you're back to writing js, and the value inside links={...} isn't valid js.
    – Alex Guerra
    Apr 6 at 22:44















up vote
3
down vote

favorite












I was trying to add a favicon in the <Helmet/> tag of a React App



my current <Helmet/> tag looks like this.



<Helmet
title="ABC"
meta={[
{ name: "ABC", content: "ABC" }
]}
links={
rel='icon',
type='image/png',
sizes='16x16',
href={require('favicon.ico')}
}

/>


But I'm getting an error about an unexpected token, any inputs on how to add a favicon? Thanks for the help in advance.










share|improve this question






















  • Just fyi: when you open braces in jsx you're back to writing js, and the value inside links={...} isn't valid js.
    – Alex Guerra
    Apr 6 at 22:44













up vote
3
down vote

favorite









up vote
3
down vote

favorite











I was trying to add a favicon in the <Helmet/> tag of a React App



my current <Helmet/> tag looks like this.



<Helmet
title="ABC"
meta={[
{ name: "ABC", content: "ABC" }
]}
links={
rel='icon',
type='image/png',
sizes='16x16',
href={require('favicon.ico')}
}

/>


But I'm getting an error about an unexpected token, any inputs on how to add a favicon? Thanks for the help in advance.










share|improve this question













I was trying to add a favicon in the <Helmet/> tag of a React App



my current <Helmet/> tag looks like this.



<Helmet
title="ABC"
meta={[
{ name: "ABC", content: "ABC" }
]}
links={
rel='icon',
type='image/png',
sizes='16x16',
href={require('favicon.ico')}
}

/>


But I'm getting an error about an unexpected token, any inputs on how to add a favicon? Thanks for the help in advance.







reactjs favicon react-helmet






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Apr 6 at 22:34









UWGOOSE

67211




67211












  • Just fyi: when you open braces in jsx you're back to writing js, and the value inside links={...} isn't valid js.
    – Alex Guerra
    Apr 6 at 22:44


















  • Just fyi: when you open braces in jsx you're back to writing js, and the value inside links={...} isn't valid js.
    – Alex Guerra
    Apr 6 at 22:44
















Just fyi: when you open braces in jsx you're back to writing js, and the value inside links={...} isn't valid js.
– Alex Guerra
Apr 6 at 22:44




Just fyi: when you open braces in jsx you're back to writing js, and the value inside links={...} isn't valid js.
– Alex Guerra
Apr 6 at 22:44












2 Answers
2






active

oldest

votes

















up vote
3
down vote













If you are using react-helmet in your project then I think one issue with your code is that link should be singular, not the plural 'links'



Try this



import Helmet from 'react-helmet'

...

<Helmet>
<title>ABC</title>
<meta name="ABC" content: "ABC" />
<link rel="icon" type="image/png" href="favicon.ico" sizes="16x16" />
</Helmet>





share|improve this answer




























    up vote
    0
    down vote













    Try this please. You written wrong keyword(links => link)



    <Helmet
    title="ABC"
    meta={[
    { name: "ABC", content: "ABC" }
    ]}
    link={[
    {"rel": "icon",
    "type": "image/png",
    "href": "favicon.ico"
    }
    ]}
    />





    share|improve this answer








    New contributor




    sekercan cepni is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.


















      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',
      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%2f49701856%2fadding-favicon-to-helmet-in-react%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








      up vote
      3
      down vote













      If you are using react-helmet in your project then I think one issue with your code is that link should be singular, not the plural 'links'



      Try this



      import Helmet from 'react-helmet'

      ...

      <Helmet>
      <title>ABC</title>
      <meta name="ABC" content: "ABC" />
      <link rel="icon" type="image/png" href="favicon.ico" sizes="16x16" />
      </Helmet>





      share|improve this answer

























        up vote
        3
        down vote













        If you are using react-helmet in your project then I think one issue with your code is that link should be singular, not the plural 'links'



        Try this



        import Helmet from 'react-helmet'

        ...

        <Helmet>
        <title>ABC</title>
        <meta name="ABC" content: "ABC" />
        <link rel="icon" type="image/png" href="favicon.ico" sizes="16x16" />
        </Helmet>





        share|improve this answer























          up vote
          3
          down vote










          up vote
          3
          down vote









          If you are using react-helmet in your project then I think one issue with your code is that link should be singular, not the plural 'links'



          Try this



          import Helmet from 'react-helmet'

          ...

          <Helmet>
          <title>ABC</title>
          <meta name="ABC" content: "ABC" />
          <link rel="icon" type="image/png" href="favicon.ico" sizes="16x16" />
          </Helmet>





          share|improve this answer












          If you are using react-helmet in your project then I think one issue with your code is that link should be singular, not the plural 'links'



          Try this



          import Helmet from 'react-helmet'

          ...

          <Helmet>
          <title>ABC</title>
          <meta name="ABC" content: "ABC" />
          <link rel="icon" type="image/png" href="favicon.ico" sizes="16x16" />
          </Helmet>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Apr 6 at 23:04









          Lucas Kellner

          1114




          1114
























              up vote
              0
              down vote













              Try this please. You written wrong keyword(links => link)



              <Helmet
              title="ABC"
              meta={[
              { name: "ABC", content: "ABC" }
              ]}
              link={[
              {"rel": "icon",
              "type": "image/png",
              "href": "favicon.ico"
              }
              ]}
              />





              share|improve this answer








              New contributor




              sekercan cepni is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.






















                up vote
                0
                down vote













                Try this please. You written wrong keyword(links => link)



                <Helmet
                title="ABC"
                meta={[
                { name: "ABC", content: "ABC" }
                ]}
                link={[
                {"rel": "icon",
                "type": "image/png",
                "href": "favicon.ico"
                }
                ]}
                />





                share|improve this answer








                New contributor




                sekercan cepni is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.




















                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  Try this please. You written wrong keyword(links => link)



                  <Helmet
                  title="ABC"
                  meta={[
                  { name: "ABC", content: "ABC" }
                  ]}
                  link={[
                  {"rel": "icon",
                  "type": "image/png",
                  "href": "favicon.ico"
                  }
                  ]}
                  />





                  share|improve this answer








                  New contributor




                  sekercan cepni is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  Try this please. You written wrong keyword(links => link)



                  <Helmet
                  title="ABC"
                  meta={[
                  { name: "ABC", content: "ABC" }
                  ]}
                  link={[
                  {"rel": "icon",
                  "type": "image/png",
                  "href": "favicon.ico"
                  }
                  ]}
                  />






                  share|improve this answer








                  New contributor




                  sekercan cepni is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  share|improve this answer



                  share|improve this answer






                  New contributor




                  sekercan cepni is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  answered 19 hours ago









                  sekercan cepni

                  1




                  1




                  New contributor




                  sekercan cepni is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.





                  New contributor





                  sekercan cepni is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.






                  sekercan cepni is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.






























                       

                      draft saved


                      draft discarded



















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f49701856%2fadding-favicon-to-helmet-in-react%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

                      A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

                      Calculate evaluation metrics using cross_val_predict sklearn

                      Insert data from modal to MySQL (multiple modal on website)