Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BreadcrumbList itemListElement listitem with string item value #257

Closed
throwaway20210 opened this issue Mar 13, 2021 · 5 comments
Closed
Labels
bug Issues describing a bug or pull requests fixing a bug.

Comments

@throwaway20210
Copy link

throwaway20210 commented Mar 13, 2021

Is it possible to produce JSON like this using this library ?

      "@context": "https://schema.org",
      "@type": "BreadcrumbList",
      "itemListElement": [{
        "@type": "ListItem",
        "position": 1,
        "name": "Books",
        "item": "https://example.com/books"
      },{
        "@type": "ListItem",
        "position": 2,
        "name": "Science Fiction",
        "item": "https://example.com/books/sciencefiction"
      },{
        "@type": "ListItem",
        "position": 3,
        "name": "Award Winners"
      }]
    }

I tried but I get a compiler error when assigning a string to item

@throwaway20210 throwaway20210 added the bug Issues describing a bug or pull requests fixing a bug. label Mar 13, 2021
@RehanSaeed
Copy link
Owner

@throwaway20210
Copy link
Author

No, I need itemListElement.*.item to be a string, not an object, that unit test does not show that.

@Turnerj
Copy link
Collaborator

Turnerj commented Mar 14, 2021

Hey @throwaway20210 , unfortunately Schema.org has the property item on ListItem as Thing, meaning it can only be an object. See: https://schema.org/ListItem

Using the example for JSON-LD on Schema.org for BreadcrumbList, the way you could implement what you want with objects would be similar to the following:

{
	"@context": "https://schema.org",
	"@type": "BreadcrumbList",
	"itemListElement": [{
		"@type": "ListItem",
		"position": 1,
		"item": {
			"@type": "Thing",
			"name": "Books",
			"url": "https://example.com/books"
		}
	},{
		"@type": "ListItem",
		"position": 2,
		"item": {
			"@type": "Thing",
			"name": "Science Fiction",
			"url": "https://example.com/books/sciencefiction"
		}
	},{
		"@type": "ListItem",
		"position": 3,
		"item": {
			"@type": "Thing",
			"name": "Award Winners",
			"url": "https://example.com/books/sciencefiction/awardwinners"
		}
	}]
}

You shouldn't have a problem achieving the above through Schema.NET. In theory, you could use the name and URL properties on ListItem directly but it really depends on the receiving side of the Schema.org data to whether they would understand that.

Alternatively to using type "Thing" for the items, you could specify "WebPage" instead as they are all web pages.

As an aside, breadcrumbs is actually a kinda weird schema representation. As a concept, they only exist with web pages so you would think a restriction to an item list that only has web pages would make sense. Yet because of using the shared ListItem type, no such restriction can exist so the item types could be any schema type at all.

@AlizerUncaged
Copy link

AlizerUncaged commented Nov 28, 2023

I'd like to point out that isn't that case for Google, Google uses item rather than URL https://developers.google.com/search/docs/appearance/structured-data/breadcrumb and I've checked on my webmaster page that using url renders the BreadcrumbList invalid, it will hurt SEO if we're not following Google

image

@Turnerj
Copy link
Collaborator

Turnerj commented Dec 16, 2023

@AlizerUncaged What you see with Google taking a Url or a Thing is Google deviating from the schema.org standard which is where we generate our entire model from - if you want to complain to anyone, its either the people who wrote the standard or Google for not following it. The screenshot you got of their docs does say you can use a Thing with the @id property set to the URL you want. You should be able to do that today with Schema.NET

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues describing a bug or pull requests fixing a bug.
Projects
None yet
Development

No branches or pull requests

4 participants