htmlschema.orgmicrodata

How to create markup for FAQ component in Microdata?


How to create Microdata markup for FAQ component when the page itself is not FAQ?

The following example is based on Google Microdata https://developers.google.com/search/docs/advanced/structured-data/faqpage but Rich Results Tool (https://search.google.com/test/rich-results) doesn't seem to recognize that at all. Unless HTML root element has additional attributes <html itemscope itemtype="https://schema.org/FAQPage">, only in that case it works. But I would prefer to have Microdata FAQs (with different content) also on some other page types so these pages will have different itemtype on root.

<div itemscope itemprop="mainEntity" itemtype="https://schema.org/Question">
    <h2 itemprop="name">Question 1</h2>
    <div itemscope itemprop="acceptedAnswer" itemtype="https://schema.org/Answer">
        <div itemprop="text">
            Text text text
        </div>
    </div>
</div>
<div itemscope itemprop="mainEntity" itemtype="https://schema.org/Question">
    <h2 itemprop="name">Question 2</h2>
    <div itemscope itemprop="acceptedAnswer" itemtype="https://schema.org/Answer">
        <div itemprop="text">
            Text text text
        </div>
    </div>
</div>

Solution

  • Please check this:

    <div itemscope itemtype="https://schema.org/FAQPage"> 
    <div itemscope itemprop="mainEntity" itemtype="https://schema.org/Question">
        <h2 itemprop="name">Question 1</h2>
        <div itemscope itemprop="acceptedAnswer" itemtype="https://schema.org/Answer">
            <div itemprop="text">
                Text text text
            </div>
        </div>
    </div>
    <div itemscope itemprop="mainEntity" itemtype="https://schema.org/Question">
        <h2 itemprop="name">Question 2</h2>
        <div itemscope itemprop="acceptedAnswer" itemtype="https://schema.org/Answer">
            <div itemprop="text">
                Text text text
            </div>
        </div>
    </div>
    </div>