In my .NET Core Web App I use the library (NuGet package) Schema.NET which appends the following JSON-LD (the library doesn't really matter because it's clearly not its fault):
<script type="application/ld json">
{
"@context":"https://schema.org",
"@type":"WebSite",
"name":"example.com",
"alternateName":"example.com - My favourite website",
"url":"https://example.com"
}
</script>
This gets added right after the title tag (in head) just like in Google's example.
The problem is that when I use the rich results test from Google the crawler successfully crawls the website, SEES the code in there and still says there's no rich content or whatever you wanna call it. Why?? What did I do wrong here?
My relevant C# code used to generate the JSON-LD above:
@{
var website = new WebSite()
{
AlternateName = "example.com - My favourite website",
Name = "example.com",
Url = new Uri("https://example.com")
};
var jsonLd = website.ToString();
}
<script type="application/ld json">
@* THIS IS NOT PROTECTED AGAINST XSS AND SIMILAR, MEANING YOU CAN ONLY USE TRUSTED VALUES HERE A.K.A. NO USER INPUT HERE!! *@
@Html.Raw(jsonLd)
</script>
Please note that the output is actually minimized a.k.a. without unnecessary whitespaces, but for better visibility I added newlines and etc, which doesn't help for Googlebot according to the rich results test tool either...
CodePudding user response:
The Rich Result Tester only reports on Structured Data that contributes to Rich Results in Google.
Their Search Gallery is a good place to learn about what can cause Rich Results:
https://developers.google.com/search/docs/advanced/structured-data/search-gallery