What is the best way to implement Schema in HTML?

Asked

Viewed 38 times

4

Giving a search on the internet I saw that Google recommends the implementation of Schema via JSON/LD.

As much as I’ve done a lot of research, I haven’t found any answers that specific. My first question is whether there is any difference in performance between putting the script within <head> or at the end of </body>.

And if there is a performance loss using at the end of </body> (or in the middle of the body), it would be preferable to use the Microdata format?

  • I marked it as a duplicate and the other is a different question. One of the questions has already been answered yes and I don’t know how it can be more specific. The other question would be interesting a larger context.

  • I do not agree with the closing and voted to reopen, there is much more to the question than simply whether a JS should come at the beginning or end of the document. It’s not just a question of page rendering but how Google’s Crawler works. Nothing about SEO, Microdata or schema is covered in duplicates... And I believe that the "if there is a loss of performance" AP is talking about SEO and not rendering, since it’s not even possible to tell if the Google bot will render anything...

  • 2

    JSON/LD are metadata in the JSON format to get around the problem that the vast majority of developers don’t know how to write HTML (correctly). They know syntax, but they don’t know semantics. The only difference is that it increases the payload of the page, as it is a few hundred bytes more to deliver to the customer. For content indexing systems, which will analyze JSON/LD, localization should not make much difference. If the system only does this, ideally it would be better to put as soon as possible, because the data will be analyzed through a stream and can ignore everything else.

  • 1

    For the vast majority of pages this possible difference will be negligible and even if it exists it won’t even make a difference to you, because it will only affect the application that is indexing the content and depends only on its implementation, Some may even suggest putting JSON at the top of the page and others at the bottom. For you, put where it is most convenient.

  • 1

    So you don’t waste time waiting for it to reopen, or not, here you can find out, https://developers.google.com/search/docs/guides/intro-structured-data?hl=pt-BR you will see that JSON can come anywhere, and that even it can be injected into the page by another JS that Google will still interpret. You don’t have to worry about page performance or rankings in this case. Or in general the use of Microdata and Jason may depend on the size of the project etc., pq gets work write the schma right on the tag, it’s almost the same as making a whole site by writing the CSS right into the tags

  • I believe the closure problem started because the AP called JSON-LD script, then implied that his question would be answered in duplicate. Anyway, JSON-LD can appear in <head> or in the <body> and I believe no change of performance because its MIME Type, application/ld+json is not run by the browser, just read. As it is not JS or CSS, there is no locking in rendering.

  • Perhaps I expressed myself in the wrong way, when I spoke about performance I meant the way Google analyzes, not the performance of my website. Anyway, I asked the question almost sure I had some delay in rendering yes, since the speed tests were better when I took JSON/LD out of my <head>. I’m in doubt now. For me it would not be a problem to mark via Microdata, because I’m still starting the project. Even so, the JSON at the end of <body> seems to be the best, since it is recommended.

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.