markup will not validate and google throws errors
-
When creating structured data the xplainer plugin seems to generate data that throws errors and will prevent google from indexing the information on the page. A typical snippet of data from xplainer generates like below. Note the @type”:null section
<script type="application/ld+json"> FAQPage{"@context":"https://schema.org","@type":null,"mainEntity":[{"@type":"Question","acceptedAnswer"
The snippet provided most likely wouldn’t throw errors in the traditional sense because it’s not actual code meant to be executed. It’s JSON-LD formatted data embedded in a script tag. However, there are a couple of potential issues to consider:
- <strong class=””>Invalid JSON: The <code class=””>@type property for the mainEntity object is set to <code class=””>null. In valid JSON, all properties should have a valid data type like string, number, or object.
- Unnecessary comments: The comments wrapped in
are meant for HTML and wouldn’t be interpreted by JSON parsers. These comments might cause issues if the data is being validated strictly.
While these wouldn’t cause errors during execution, they might lead to parsing warnings or unexpected behavior depending on how the data is being used.
Here’s how you can fix the snippet:
- Change <code class=””>”@type”: null to a valid type, like <code class=””>”@type”: “ItemList” (assuming this is a list of questions and answers).
- Remove the HTML comments within the answer text.
Here’s an example of the corrected snippet:
JSON
<script type="application/ld+json"> { "@context": "https://schema.org", "@type": "FAQPage", "mainEntity": [ { "@type": "Question",
- The topic ‘markup will not validate and google throws errors’ is closed to new replies.