Graphics Cove

How to Add Structured Data to Gatsby

Structured data describes precisely what the content of your website is, and are complementary to meta tags. You can, for example, describe anything you like, such as movie, a recipe or an article.

This structured data gives the opportunity for Google to displayed your pages differently in search results. In addition, these are always displayed at the top of results, which puts your website in the best position for getting that click through.

Using React Helmet

To add structured data with Gatsby, Helmet is the best tool. JSON-LD is the language used by structured data, so let's start by creating a component to output this:

import React from 'react'
import Helmet from 'react-helmet'

export function StructuredData({ children }) {
	return (
			<script type="application/ld+json">{JSON.stringify(children)}</script>

Then you can import the component to add structured data in your pages:

import React from 'react'
import { Helmet } from 'react-helmet'
import { StructuredData } from '../components/structuredData'

export default function index() {
  return (
        <title>My Website</title>
        <description>Website Description</description>
            '@context': '',
            '@type': 'Organization',
            url: '',
            name: 'Website Name',
            contactPoint: {
              '@type': 'ContactPoint',
              telephone: '+44 00000 000 000',
              contactType: 'Support',
      <h1>My Website Heading</h1>

Use the Rich Results Test provided by Google to make sure you've set everything up correctly and check your data is coming through as expected. And there you go! How to add structured data to Gatsby!

© 2010 - 2023 Graphicscove

TwitterFacebookFAQsPrivacy PolicyFree Website Review