Google reads structured data from a web page. This is in the form:
<script type="application/ld+json">
@StructuredData
</script>
And the @StructuredData
getter must be populated in the pre-render call to OnInitializedAsync()
. And this all works great except for one thing.
While the final page does show:
<script type="application/ld+json">
@StructuredData
</script>
The page is displayed in Google's test as:
<script type="application/ld+json">
@StructuredData
</script>
And because of that, Google does not find the data. My guess is that the pre-render pass encodes the +
for some reason and the final pass does not. But maybe it's something else.
Any idea what is going on? And more important, how I can fix it?
I don't know why this makes a difference. And I wish I understood what is going on here. But this fixes it. I had:
<script type="application/ld+json">
@StructuredData
</script>
I changed it to:
@StructuredData
where I moved the <script>
part inside the @StructuredData
property which returns a MarkupString
.
I understand why putting everything inside the MarkupString
means that will all be written out literally. What I don't understand is why Blazor converted the +
in the page returned to Google on the pre-render pass, but it is a literal +
on the final render.
But a solution gets the job done.