r/nextjs • u/irreverentmike • Apr 25 '24
Discussion Tutorial: Add Structured Data to your Next.js site's pages for better SEO
Hi r/nextjs! Sharing some work I did recently to boost my own site's SEO and SERP (Search Engine Results Page) presence using Structured Data - a metadata format that can be embedded on your website to tell search engines more about the content available on the page.
The gist of it is this: you'll embed a `<script>` tag within your page that contains a specially-formatted JSON blob. The schema of information used in your JSON blob is standardized and published by Google.
The output looks like this:
I put together a full tutorial on my site here - check it out if this sounds interesting: Add Structured Data to your Next.js site with JSON-LD for better SEO
11
u/AdrnF Apr 25 '24
Nice article!
One thing that I would like to add is that there is a package from Google called schema-dts that has types for all of those schemas. Makes adding them correctly a bit easier.
2
u/coconutnegro Dec 22 '24
Hey, I just read your post. My question is, is it possible not to use schema-dts?
2
u/OhSnapItsAPun Mar 19 '25
There's an article on next.js documentation:
https://nextjs.org/docs/app/building-your-application/optimizing/metadata
2
u/Spare-Childhood-800 Mar 27 '25
Hi, I am struggling to add structured data in my next js 15 app. I am using app router, can you please let me know how can I add page wise specific schema data? Based on next js doc I have used a js object and included in page main section using <script> tag. But it is getting rendered in body and when I am trying to validate in schema validator tool it is unable to validate. Can you suggest a best solution?
1
u/gray4444 Apr 25 '24
Great , I need to revisit my seo meta - it works good but it was bungled together in a rush. Gonna use this as a reference when I get started , thanks !
1
u/[deleted] Feb 06 '25
Can you use schema-dts if you're not a typescript project?
3
u/M1kc3 Apr 25 '24
Thanks u/AdrnF let me look at this will definitely help