Tahsin Khan
Tahsin Khan

Reputation: 61

How can I add Google Structured data on my gatsby website?

I want to add google structured data for my gatsby website. But I can't find any detailed information on that.

I tried to use google tag manager but it doesn't seems to work.

I am seeking for a way to add google structure data on my website. I want an article schema for all my pages except the home page. And FAQ schema for home page.

Upvotes: 6

Views: 2311

Answers (1)

Mark Michon
Mark Michon

Reputation: 735

Looks like what you want is to combine the concepts of the SEO component, as described here: https://www.gatsbyjs.org/docs/add-seo-component/ and react-helmet's support for the script tag: https://github.com/nfl/react-helmet#reference-guide

The prismic starter by LekoArts does this. Here's the file for reference: https://github.com/LeKoArts/gatsby-starter-prismic/blob/master/src/components/SEO/SEO.jsx

Now to make them different for the home page vs your article pages, you'll likely need to amend the component to accept whatever data you want to pass down from the article.

Upvotes: 6

Related Questions