0

I am fairly new to React, GraphQL and Gatsby. I am following along with the tutorial and cannot quite figure out where the <link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet"> tag is supposed to go...

Here is my layout.js file...

import React from 'react'
import PropTypes from 'prop-types'
import Helmet from 'react-helmet'
import {StaticQuery, graphql} from 'gatsby'
import Header from './header'
import './css/style.css'
import Footer from './footer'

const Layout = ({ children }) => (
  <StaticQuery
    query={graphql`
      query SiteTitleQuery {
        site {
          siteMetadata {
            title
            description
            keywords
          }
        }
        allContentfulLink (sort: { fields: [createdAt], order: ASC }) {
          edges {
            node {
              title
              url
              createdAt
            }
          }
        }
      }
    `}
    render={data => (
      <>
        <Helmet
          title={data.site.siteMetadata.title}
          meta={[
            { name: 'description', content: data.site.siteMetadata.description },
            { name: 'keywords', content: data.site.siteMetadata.keywords },
          ]}
        >
          <html lang="en" />
        </Helmet>
        <Header siteTitle={data.site.siteMetadata.title}/>
          {children}
          <Footer data={data}>
          </Footer>
      </>
    )}
  />
)

Layout.propTypes = {
  children: PropTypes.node.isRequired,
}

export default Layout

I have attempted to add the in the helmet, opening the tag and inserting inside of there and both receive errors.

I am not sure what I am doing wrong.

Any assistance is greatly appreciated!!

Hyyan Abo Fakher
  • 3,497
  • 3
  • 21
  • 35
TylerYoc
  • 75
  • 2
  • 10
  • You could try importing the Google font into CSS as explained in this answer: https://stackoverflow.com/questions/14676613/how-to-import-google-web-font-in-css-file – Bonnie Sep 10 '18 at 20:43

1 Answers1

0

The easiest way is going to be adding gatsby-plugin-web-font-loader to your package.json and then configuring the plugin in gatsby-config.js:

{
  plugins: [
    {
      resolve: 'gatsby-plugin-web-font-loader',
      options: {
        google: {
          families: ['Nunito']
        }
      }
    }
  ]
}
coreyward
  • 77,547
  • 20
  • 137
  • 166