I am trying to add Schema structured data to my website.
I have one page for my app with:
{
"#context": "https://schema.org",
"#type": "MobileApplication",
"#id": "https://example.com/app",
"name": "APP",
"applicationCategory": "HealthApplication",
"operatingSystem": ["iOS", "Android"],
"offers": {
"#type": "Offer",
"price": "0",
"priceCurrency": "USD"
},
"aggregateRating": {
"#type": "AggregateRating",
"ratingValue": "5",
"ratingCount": "100"
}
}
...and another for my company:
{
"#context": "https://schema.org",
"#type": "Corporation",
"#id": "https://example.com/about",
"name": "COMPANY",
"owns": {
"#type": "MobileApplication",
"#id": "https://example.com/app"
}
}
When I test the above with https://search.google.com/test/rich-results, the app page is fine, but the company page gives the following error:
Am I misunderstanding how #id works? I thought Google would then look for the linked resource and get all the missing properties.
reference them by using just the #id keyword, omit the #type keyword:
{
"#context": "https://schema.org",
"#type": "Corporation",
"#id": "https://example.com/about",
"name": "COMPANY",
"owns": {
"#id": "https://example.com/app"
}
}
However, Google doesn't seem to utilize #id keyword in a way that it links snippets on the internet, especially ones that are on different pages, or sites, or at least there are no benefits in SERP
Also, corporation markup could be improved: property owns expects a Product type, and MobileApplication is a subtype of CreativeWork, so it's probably not appropriate, however, there seems to be no straightforward property that connects Organization and CreativeWork, although Google doesn't seem to complain about it
Related
I'm struggling to understand how to properly format the citation property for Articles on a website. The documentation only indicates it accepts Text or CreativeWork types, but how would I add multiple? Can I make it an array?
Right now I have something like this:
[{
"#context": "http:\/\/schema.org",
"#type": "Article",
"mainEntityOfPage": {
"#type": "WebPage",
"#id": "https:\/\/bhamrick.com\/article-url\/"
},
"url": "https:\/\/bhamrick.com\/article-url\//",
"headline": "Article Title",
"description": "This is an excerpt from the article",
"image": {
"#type": "ImageObject",
"url": "https:\/\/cdn.bhamrick.com\/article-image.jpg",
"width": 1200,
"height": 628
},
"datePublished": "2019-12-10T18:10:23-08:00",
"dateModified": "2020-02-26T18:24:00+00:00",
"author": {
"#type": "Person",
"name": "Bryce Hamrick",
"url": "",
"description": "This is my bio.",
"sameAs": ["https:\/\/bhamrick.com\/", "https:\/\/twitter.com\/https:\/\/twitter.com\/bhamrick"]
},
"publisher": {
"#type": "Organization",
"#id": "https:\/\/bhamrick.com\/#organization",
"name": "Bryce Hamrick",
"logo": {
"#type": "ImageObject",
"#id": "https:\/\/bhamrick.com\/#logo",
"url": "https:\/\/cdn.bhamrick.com\/logo.png",
"width": 600,
"height": 60
},
"image": {
"#type": "ImageObject",
"#id": "https:\/\/bhamrick.com\/#logo",
"url": "https:\/\/cdn.bhamrick.com\/logo.png",
"width": 600,
"height": 60
}
},
"articleSection": "Article Category",
"keywords": "",
"wordCount": 5151,
"citation": []
}]
For the "citation" property, should I change it to look like this?
"citation: [
{
"#type": "CreativeWork",
"sameAs": "https:\/\/www.ncbi.nlm.nih.gov\/pmc\/articles\/01234567\/"
}, {
"#type": "CreativeWork",
"sameAs": "https:\/\/www.ncbi.nlm.nih.gov\/pmc\/articles\/567891011\/"
}
]
What other data is beneficial to include for crawlers like Google?
If you test your code (with the citation array) on the Structured Data Testing Tool - it will come through as valid. Making citation an array is acceptable there, so I'd say that's a fine way to handle it.
As far as what else you can add to each CreativeWork, that would depend on what each CreativeWork is. For that you can reference what is available at the schema.org specification for CreativeWork.
I'd note that while Google validates citation in your example, there's not much about it on Google Structured Data Documentation. Even if it's a good structured data practice, you may not gain much SEO benefit from this - but that's a better question to bring up on Webmasters Stack Exchange.
Just to chime in, I'm using the 'url' property, I think that's more accurate for this purpose, although both are probably valid.
My logic is: If you haven't defined something, how can it be the 'sameAs' something else?
"citation: [
{
"#type": "CreativeWork",
"url": "https:\/\/www.ncbi.nlm.nih.gov\/pmc\/articles\/01234567\/"
}, {
"#type": "CreativeWork",
"url": "https:\/\/www.ncbi.nlm.nih.gov\/pmc\/articles\/567891011\/"
}
]
I am relatively new to building APIs and have come across the following two terms a few times now and am a bit confused. I'm hoping someone can put me straight with some definitions that I cannot even find on wikipedia. Im not sure if they can be reliably used interchangeably without upsetting people or whether it depends on who you talk to.
Sideloading
the ability to optionally include other related resource(s) in a response
eg. /accounts?include=transactions will include transactions resources in my /accounts resources response ?
this really means that we avoid duplication of resources in a response by moving them out into their own section of the message, eg.instead of
{ "orders": [ {
"id": "101",
"product": { "id": "2000", "desc": "blah", "price": "100.0" }
"id": "102",
"product": { "id": "2000", "desc": "blah", "price": "100.0" }
we would have:
{ "orders": [ {
"id": "101",
"product": { "id": "2000" }
"id": "102",
"product": { "id": "2000" }
],
"products": [
{ "id": "2000", "desc": "blah", "price": "100.0" }
Composite Document
Simply means you have a mix of related resources (that can also stand alone) in a resources response eg. accounts and transactions resources can be requested on their own or also combined in the same composite document ??
I've never come across what I would consider a formal definition of either sideloading or composite, I reckon you can define it how you want, provided its consistent with how your resources are modelled.
I cant imagine people getting too upset about the terminology. The basic premise is sound, everything else is just semantics and implementation :). That said, it's a good idea to keep your API object model relatively pure and functional for the client.
So if it is most likely to be used in the nested product fashion, and thats what the API naturally looks like, then the duplication of
{ "orders": [ {
"id": "101",
"product": { "id": "2000", "desc": "blah", "price": "100.0" }
"id": "102",
"product": { "id": "2000", "desc": "blah", "price": "100.0" }
might be less of a problem than the added indirection of
{ "orders": [ {
"id": "101",
"product": { "id": "2000" }
"id": "102",
"product": { "id": "2000" }
],
"products": [
{ "id": "2000", "desc": "blah", "price": "100.0" }
I try to create my own Context for a project. However, after using Compact some Properties will be missing. Please see this example:
{
"#context":
{
"myvocab": "http://localhost:8080/schema.json#",
"Information":
{
"#id": "myvocab:Information",
"#type": "#id",
"name": "http://schema.org/name",
"active": "http://schema.org/Boolean"
}
},
"Information": [
{
"#type": "myvocab:Information",
"name": "myCustomName",
"active": "true"
}
]
}
This example can also be found on the JSON-LD Playground.
After Compacting, I cannot see the properties "name" and "active" anymore as they will be removed. This is also the case in the playground. However, I do not get an error in the #context part, so I assume it is correct.
Please help me to understand why that properies go missing and what I could do to see them correctly after parsing.
Thanks in advance!
The nesting of your context is wrong. You mistakenly made name and active attributes of the Information mapping instead of making them term mappings on their own. Here's the fixed example:
{
"#context":
{
"myvocab": "http://localhost:8080/schema.json#",
"Information":
{
"#id": "myvocab:Information",
"#type": "#id"
},
"name": "http://schema.org/name",
"active": "http://schema.org/Boolean"
},
"Information": [
{
"#type": "myvocab:Information",
"name": "myCustomName",
"active": "true"
}
]
}
You might also want to check the mapping of active. You map it to a type instead of mapping it to a property (properties are lowercased in Schema.org, classes/types capitalized).
is there actually a possibility to get the number of followers of my googleplus-page. the following script - which I found here in an earlier post - doesn't work (no output):
$google_api_key = 'XYZXYZXYZXYZXYZXYZ';
$page_id = 'MYNUMERICPAGEID';
$data = #file_get_contents("https://www.googleapis.com/plus/v1/people/$page_id?key=$google_api_key");
$data = json_decode($data, true);
echo $data['plusOneCount'];
thank you!
There could be a few things wrong:
Don't have an updated project on the Developer Console.
Didn't enable the API for that project.
Are past thresholds/quotas.
Try the following:
Login to your Google Developers Console
You'll need a project.
If you don't have a project, create one.
Enable "Google Plus API" on that project.
Confirm usage/quotes are within tolerance and you haven't gone past.
From there, your call should work as normal:
GET https://www.googleapis.com/plus/v1/people/{USER_ID}?key={YOUR_API_KEY}
In my case, I'm querying Google's's page, so {USER_ID} = 116899029375914044550. I can then see the plusOneCount:
{
"kind": "plus#person",
"etag": "\"RqKWnRU4WW46-6W3rWhLR9iFZQM/bTf-sq_Sg3fLAFijixPfjtKM5f8\"",
"urls": [
{
"value": "http://www.google.com",
"type": "website",
"label": "www.google.com"
},
{
"value": "http://www.google.com/support/",
"type": "other",
"label": "Google Help"
},
{
"value": "http://googleblog.blogspot.com/",
"type": "other",
"label": "Official Blog"
},
{
"value": "http://twitter.com/#!/google",
"type": "other",
"label": "#google"
},
{
"value": "http://www.google.com/about/corporate/company/",
"type": "other",
"label": "Company Info"
},
{
"value": "http://www.google.com/press/",
"type": "other",
"label": "News"
},
{
"value": "http://www.google.com/press/google-directory.html",
"type": "other",
"label": "More Google pages"
}
],
"objectType": "page",
"id": "116899029375914044550",
"displayName": "Google",
"tagline": "News and updates on Google's products, technology and more",
"aboutMe": "<p>Welcome to Google's official page. Here, you'll find product news and announcements, company updates, glimpses into what it's like to work at Google, discussions on technology and the web, and much more. </p><p><span>Given the volume of feedback we receive here, we may not be able to respond individually to every comment and we're not able to provide product support (if you're having product issues, please visit our Help Center). Rest assured we're paying attention, and we're always eager to hear from you.</span></p>",
"url": "https://plus.google.com/+google",
"image": {
"url": "https://lh4.googleusercontent.com/-v0soe-ievYE/AAAAAAAAAAI/AAAAAAAC9wQ/JD8tdz3bFTM/photo.jpg?sz=50",
"isDefault": false
},
"isPlusUser": true,
"plusOneCount": 10757884,
"circledByCount": 7692912,
"verified": true,
"cover": {
"layout": "banner",
"coverPhoto": {
"url": "https://lh4.googleusercontent.com/-PLPoXvnN0XI/UTdr4xTtuHI/AAAAAAAA_1U/p1n_Za3BZUg/s630-fcrop64=1,00000000fe06fe97/g_plus_background.png",
"height": 528,
"width": 940
},
"coverInfo": {
"topImageOffset": 0,
"leftImageOffset": 0
}
}
}
After reading the documentation, testing and reading a lot of other questions here on stackoverflow:
We have documents that have titles and description in multiple languages. There are also tags that are translated to the same languages. There might be up to 30-40 different languages in the system, but probably only 3 or 4 translations for a single document.
This is the planned document structure:
{
"luck": {
"id": 10018,
"pub": 0,
"pr": 100002,
"loc": {
"lat": 42.7,
"lon": 84.2
},
"t": [
{
"lang": "en-analyzer",
"title": "Forest",
"desc": "A lot of trees.",
"tags": [
"Wood",
"Nature",
"Green Mouvement"
]
},
{
"lang": "fr-analyzer",
"title": "ForĂȘt",
"desc": "A grand nombre d'arbre.",
"tags": [
"Bois",
"Nature",
"Mouvement Vert"
]
}
],
"dates": [
"2014-01-01T20:00",
"2014-06-06T20:00",
"2014-08-08T20:00"
]
}
}
Possible queries are "arbre" or "wood" or "forest" or "nature" combined with a date and a geo_distance filter, furthermore there will be some facets over the tags array (that obviously include counting).
We can produce any document structure that fits best for elasticsearch (or for lucene). It's crucial that each language is analyzed specifically, so we use "_analyzer" in order to distinguish the languages.
{
"luck": {
"properties": {
"id": {
"type": "long"
},
"pub": {
"type": "long"
},
"pr": {
"type": "long"
},
"loc": {
"type": "geo_point"
},
"t": {
"_analyzer": {
"path": "t.lang"
},
"properties": {
"lang": {
"type": "string"
},
"properties": {
"title": {
"type": "string"
},
"desc": {
"type": "string"
},
"tags": {
"type": "string"
}
}
}
}
}
}
A) Apparently, this idea does not work: after PUTting the mapping, we retrieve the same mapping ("GET") and it seems to ignore the specific analyzers (A test with a top-level "_analyzer" worked fine). Does "_analyzer" work for sub-documents and if yes how to should we refer to it? We also tested declaring the sub-document as "object" or "nested". How is multi-language document indexing supposed to work.
B) One possibility would be to put each language in its own document: In that case how do we manage the id? Finally both documents should refer to the same id. For example if the user searches for "nature" (and we don't know if the user intends to find "nature" in English or French), this document would appear twice in the result set, and the counting and paging would be very wrong (also facet counting).
Any ideas?