q2a / question2answer

Question2Answer is a free and open source platform for Q&A sites, running on PHP/MySQL.
http://www.question2answer.org/
GNU General Public License v3.0
1.63k stars 628 forks source link

Generate JSON-LD for structured data instead of Microdata #855

Open teddydoors opened 3 years ago

teddydoors commented 3 years ago

Google explicitly says they recommend using JSON-LD for structured data. https://developers.google.com/search/docs/guides/intro-structured-data#markup-formats-and-placement

Initially, I think it doesn't matter much. But later on when trying to customize Q2A layout to build a new theme, I realize that the way Q2A using Microdata structures make it more difficult to implement. You always have to watch out for any missing "itemprop" things, and the structure is hard to customize, especially with the order of Microdata structure elements. Sometimes you have to create a dummy DOM that is not visible to human eyes but to complete the Microdata structures. Moreover, in question lists where the structured data are not required, but "itemprop" things still exist, for example in user avatars.

So, if Google loves JSON-LD, why don't we make them overjoyed? (FYI, I see Wikipedia.org also outputs JSON-LD.)

svivian commented 3 years ago

Yes, I understand the markup argument, it was quite a hassle to update the templates to support the microdata in the HTML. But on the other hand, adding the JSON-LD is very wasteful, it repeats the entire content of the page again inside the JS. So the page is twice as slow. I'll see if there is a way around it.