-
Notifications
You must be signed in to change notification settings - Fork 556
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
Support recipe schema.org metadata from CAPI in LinkedData #26931
Conversation
82b6df7
to
5ecae05
Compare
5ecae05
to
d42f52d
Compare
dc0477c
to
803f1d1
Compare
ac1c042
to
2346feb
Compare
2346feb
to
ece9562
Compare
Update of things still outstanding:
Ideally we'd also get a test file working to check the logic for returning recipe schema org data. A possible improvement at this point might be to decode and encode the JSON object from |
4c30bae
to
1aa82d6
Compare
Where we've got to:
|
9aa97cb
to
1d6a71a
Compare
d5b1615
to
c9cfd5d
Compare
c9cfd5d
to
218c86c
Compare
Testing this in CODE and it's looking really good, valid schema coming through for a selection of single and multi-recipe articles:
Using https://validator.schema.org/ to confirm the |
Co-authored-by: frederickobrien <frederick.obrien@guardian.co.uk>
Co-authored-by: frederickobrien <frederick.obrien@guardian.co.uk>
Silly placement mistake. Fixed and verified in schema validator
218c86c
to
5d98055
Compare
Seen on ADMIN-PROD (merged by @cemms1 12 minutes and 13 seconds ago)
|
Seen on FRONTS-PROD (merged by @cemms1 14 minutes and 23 seconds ago)
|
I'm not sure if this is important, but I wanted to share that I received this warning this morning from Google Search Console ("New Recipes structured data issues detected"):
It looks like this is actually only on one url: |
Recipe structured data
Part of guardian/dotcom-rendering#10532, this is the last in a chain of PRs that will get Schema.org markup rendering on the website for recipes.
A
schemaOrg
field has been added to thecontent
field of CAPI responses (see guardian/content-api-models#237 and https://github.com/guardian/content-api/pull/2858 for more context). What arrives at Frontend is mostly valid schema, though through a quirk of Thrift field naming '_atType' and '_atContext' need to be turned into '@type' and '@context'.Once this is done the schema is converted to a
LinkedData
object and appended to the more generic article schema (or linked data as it's labelled here) already being generated and is passed on to Dotcom as before. Testing has been added to ensure data is being transformed as expected.One upside of this approach is that we don't have to touch Dotcom, though an open question remains about where is the most appropriate place to transform CAPI data into Schema.org markup. Frontend? CAPI itself? There's a bit of both now. With time - and hopefully the SEO value of this established - it might be worth centralising the Schema.org/linked open data generation.
Most of the changed files - in
data/database
- are due to an unrelated issue concerning (non)generated data files.To test deploy this branch to CODE and use https://validator.schema.org/ to check whether valid schema is being included in the
ld+json
blobs of articles containing recipe elements. #26931 (comment) contains a few example though there are hundreds by now.