问题
I have a page with multiple Question and Answers and I'm getting the following warning on each question:
Missing a QAPage markup item on page to which this item should be associated.
This is example markup:
<div itemscope="" itemtype="http://schema.org/Question">
<h3 class="question" itemprop="name text">This is the question?</h3>
<div class="answer" id="IdForTheAnswer" itemprop="acceptedAnswer" itemscope="" itemtype="http://schema.org/Answer">
<div itemprop="text">
<p>This is the answer text.</p>
</div>
</div>
</div>
And below is the example warning from https://search.google.com/structured-data/testing-tool/ :
Question | 0 ERRORS | 1 WARNING
@type
- Question
- name
- This is the question?
- text
- This is the question?
- acceptedAnswer
- @type
- Answer
- @id
- https://www.example.com/IdForTheAnswer
- text
- This is the answer text.
warning
- Missing a QAPage markup item on page to which this item should be associated.
What is this warning actually asking me to provide?
What I've tried unsuccessfully so far:
- Remove the
id
from theacceptedAnswer
- Use
suggestedAnswer
instead ofacceptedAnswer
- Provide the
Question
with amainEntityOfPage
回答1:
Ok so after an entire day of trying I finally stumbled on the answer.
I was getting that same warning if I removed everything but the question item, so it's something related to that. I tried a lot of things and on a hunch I ended up wrapping the whole collection of questions in this:
<div itemscope itemtype="http://schema.org/FAQPage">
<!-- Rest of Q&A markup -->
</div>
And now I get valid schema without any errors or warnings.
I feel like the documentation and error messages are not very good, or I just don't understand this ecosystem and its resources yet!
p.s. I also tried the QAPage
itemtype but that requires a lot more props and doesn't actually describe the page I'm building, so FAQPage
comes closest.
来源:https://stackoverflow.com/questions/52203521/schema-warning-about-qapage-on-question-type