Welcome to WebmasterWorld Guest from 35.175.191.168

Forum Moderators: open

Schema Products questions

     
12:40 am on Mar 17, 2019 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month

joined:Mar 15, 2013
posts: 1193
votes: 119


In a weak and somewhat confused attempt to make my site more schema-friendly...

1. Am I even correct that "Products" would be the most appropriate style for a Classifieds section?

2. I used this tool to check things:

[freetools.webmasterworld.com...]

In my layout I DID have a section for "url" in the page that listed all of the ads, like this:

<link itemprop="url" href="[LINK TO CLASSIFIED LISTING]">

So the link went to the page on my site with the actual ad. But the <link> element kinda messed things up because everything with the container div became a link.

The "Url" description on the generator is pretty vague; should I have even been linking to the classified listing like that? If so, is the <link> element appropriate, or should it have just been in the <a href...> link... like:

<a itemprop="url" href="[LINK TO CLASSIFIED LISTING]">
<b itemprop="name">[TITLE]</b>
</a>
2:21 am on Mar 17, 2019 (gmt 0)

Administrator from US 

WebmasterWorld Administrator not2easy is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Dec 27, 2006
posts:4522
votes: 350


Sorry I'm not much help with this. When I started with setting it up I used that free tool for checking. Google has a free schema / Rich Snippets testing tool [search.google.com] that is a little newer.
12:42 am on Mar 18, 2019 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month

joined:Mar 15, 2013
posts: 1193
votes: 119


Man, schema is a nightmare! I don't think even it knows what it's doing.

I've found 100 tutorials, and all 100 of them say 100 different things. The best I can figure, though, for my list I have this type of format:

<div itemscope itemtype="http://schema.org/ItemList">
<span itemprop="numberOfItems">315</span>

<!-- first item -->
<div itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
<meta itemprop="position" content="1">
<link itemprop="url" content="[LINK TO PRODUCT]">

<div itemprop="item" itemscope itemtype="http://schema.org/Product">
<img src="[LINK TO IMAGE]" itemprop="image">

<a itemprop="url" href="[LINK TO PRODUCT]">
<span itemprop="name">[TITLE]</span>
</a>

<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<span itemprop="price">[PRICE]</span>
</div>

<p>
<a itemprop="url" href="[LINK TO PRODUCT]">
<b itemprop="name">[TITLE]</b>
</a>
</p>

<p itemprop="description">
[DESCRIPTION]
</p>
</div>
</div>

<!-- second item -->
<div itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
<meta itemprop="position" content="2">
...
</div>
</div>


position was a pain to figure out, not having it at all gave an error, so I think I went through 50 variations before finding something that validated!

This validates, but I still get a warning that I don't understand:

@type Product
@id [shows the link to current page + the ID for the field, no idea why]
url [LINK TO PRODUCT]
name [TITLE]
description [DESCRIPTION]
offers
@type Offer
priceCurrency USD
price 100.00

[THIS IS THE UNEXPECTED WARNING]
warning - url The url field is recommended. Please provide a value if available.


I already have the URL that's validating, in the 3rd line. But this warning implies that there's a sub-listing beneath "offers" that should have the URL again?

I tried embedding the URL and NAME within another Offers set, like the example here:

[schema.org...]

Eg:

   <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<span itemprop="price">[PRICE]</span>
</div>

<p itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<a itemprop="url" href="[LINK TO PRODUCT]">
<b itemprop="name">[TITLE]</b>
</a>
</p>


But then I got errors on NAME and PRICE, and still had the same warning for URL.

Am I supposed to have another link for URL within the Offer section? If so, is it supposed to link to the current page or product page?
3:38 am on Mar 18, 2019 (gmt 0)

Senior Member

WebmasterWorld Senior Member Top Contributors Of The Month

joined:Apr 1, 2016
posts:2714
votes: 823


If you use JSON-LD then you don't need to worry about matching all the schema markup with all right tags.

you simply add the markup like so:

<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Organization",
"url": "http://www.example.com",
"name": "Unlimited Ball Bearings Corp.",
"contactPoint": {
"@type": "ContactPoint",
"telephone": "+1-401-555-1212",
"contactType": "Customer service"
}
}
</script>


example is from here:
[developers.google.com...]

Link includes a far more detailed description.
5:51 am on Mar 18, 2019 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month

joined:Mar 15, 2013
posts: 1193
votes: 119


I've never used JSON-LD, and now very little about it... how do you do that when all of the content is user-generated? And how do you link the JSON script with the PHP page?
2:01 pm on Mar 18, 2019 (gmt 0)

Junior Member

Top Contributors Of The Month

joined:Sept 26, 2018
posts:76
votes: 20


how do you do that when all of the content is user-generated? And how do you link the JSON script with the PHP page?


Auto-generate/auto-populate the JSON-LD schema with the data in your DB using PHP.

The JSON-LD <script> block(s) can be placed anywhere within the page's html as long as it passes W3C markup validation.