4

I have a FAQ page and I want to do it with better html-schema.

<main role="main" itemscope itemtype="http://schema.org/WebPage">
  <article itemprop="mainContentOfPage">
    <header>
      <h1>Frequently Asked Questions</h1>
    </header>
    <section itemscope itemtype="http://schema.org/Question">
      <h2 itemprop="name">Some question #1</h2>
      <p itemprop="suggestedAnswer acceptedAnswer" itemscope itemtype="http://schema.org/Answer">
        <span itemprop="text">This is an answer #1</span>
      </p>
    </section>
    <section itemscope itemtype="http://schema.org/Question">
      <h2 itemprop="name">Some question #2</h2>
      <p itemprop="suggestedAnswer acceptedAnswer" itemscope itemtype="http://schema.org/Answer">
        <span itemprop="text">This is an answer #2</span>
      </p>
    </section>
    <section itemscope itemtype="http://schema.org/Question">
      <h2 itemprop="name">Some question #3</h2>
      <p itemprop="suggestedAnswer acceptedAnswer" itemscope itemtype="http://schema.org/Answer">
        <span itemprop="text">This is an answer #3</span>
      </p>
    </section>
  </article>
</main>

I think a better type for the page is FAQPage instead of WebPage, but FAQPage has pending status and doesn't validate in Google Structured Data Testing Tool.

What do you think about this scheme? Is it correct?

unor
  • 92,415
  • 26
  • 211
  • 360

1 Answers1

3

FAQPage will be the best type for the page. If you don’t want to use it until it’s released, WebPage is the best alternative. You could also consider using both types for now, and remove WebPage as soon as FAQPage is part of the core vocabulary (or remove FAQPage if it goes to the attic):

<main itemscope itemtype="http://schema.org/WebPage http://schema.org/FAQPage">

I wouldn’t use the mainContentOfPage property. It expects a WebPageElement, which is typically not useful.

In your case, the Question items aren’t connected to the WebPage item. For this, you could use the hasPart property.

<main itemscope itemtype="http://schema.org/WebPage http://schema.org/FAQPage">

  <section>

    <h2 itemprop="name">Frequently Asked Questions</h2>

    <article itemprop="hasPart" itemscope itemtype="http://schema.org/Question"></article>
    <article itemprop="hasPart" itemscope itemtype="http://schema.org/Question"></article>
    <article itemprop="hasPart" itemscope itemtype="http://schema.org/Question"></article>

  </section>

</main>

(I switched the article and section elements because I think it makes more sense that way, semantically.)

unor
  • 92,415
  • 26
  • 211
  • 360
  • I think I did right way with `article > section`, because in my case sections - it's just parts of article. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/article – Sergey Eroshenkov Feb 02 '18 at 17:26
  • @SergeyEroshenkov: I don’t agree if it’s a typicaly FAQ page: users don’t need to read all question/answer pairs for it to make sense, each Q/A pair stands on its own (could have its own page, its own author, its own comments, its own feed entry etc.). Both of these can be indications that `article` is appropriate for each pair, and not for the whole thing. -- If, however, it’s not a typical FAQ page, but the question/answer pairs are integrated into an article with context (so not just a list of Q/A pairs), then `article` for the whole thing is appropriate. – unor Feb 04 '18 at 03:22
  • 1
    As of 2019-05-07, the `FAQPage` is now an official schema extension: https://schema.org/FAQPage, https://developers.google.com/search/docs/data-types/faqpage, and https://searchengineland.com/google-search-adds-support-for-faq-and-how-to-structured-data-316541 – AnhellO May 08 '19 at 22:04